# Understanding the Structured Output from AutoHedge Agents: A Complete Schema Guide

> Explore the structured output from AutoHedge agents. This guide details the JSON schema for thesis, scores, position sizing, and order objects, enabling seamless integration and analysis.

- Repository: [Swarms/AutoHedge](https://github.com/The-Swarm-Corporation/AutoHedge)
- Tags: api-reference
- Published: 2026-09-09

---

**AutoHedge agents return machine-readable JSON schemas defined in [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py), with the Director emitting plain text thesis, Quant Analyst returning technical scores, Risk Manager providing position sizing data, and Execution Agent generating broker-ready order objects.**

The AutoHedge trading system orchestrates a multi-agent pipeline where specialized LLM agents communicate through strictly defined data contracts. Each agent in the `The-Swarm-Corporation/AutoHedge` repository—except the Director—outputs structured JSON that downstream components consume for automated trading decisions.

## The Four-Agent Pipeline Architecture

AutoHedge drives a sequential workflow through four specialized agents. Three of these enforce strict structured output schemas, while the Director provides free-form contextual analysis.

### Director Agent: Textual Thesis Generation

The Director operates through the `DIRECTOR_PROMPT` template (lines 5-21 in [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py)). Unlike other agents, it returns **plain text** (e.g., "Long XYZ because...") rather than structured JSON. This textual thesis feeds into subsequent agents as contextual grounding.

### Quant Analyst Agent: Technical Evaluation Schema

The Quant Analyst produces granular market analysis via `QUANT_ANALYSIS_PROMPT` located at lines 75-90 in [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py). The agent returns a JSON object with normalized scoring:

```json
{
  "ticker": "str",
  "technical_score": 0-1,
  "volume_score": 0-1,
  "trend_strength": 0-1,
  "volatility": "float",
  "probability_score": 0-1,
  "key_levels": {
    "support": "float",
    "resistance": "float",
    "pivot": "float"
  }
}

```

### Risk Manager Agent: Position Sizing Schema

Defined in `RISK_ASSESSMENT_PROMPT` (lines 41-49 in [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py)), this agent evaluates portfolio exposure and returns:

```json
{
  "recommended_position_size": "float",
  "max_drawdown_risk": "float",
  "market_risk_exposure": "float",
  "overall_risk_score": 0-1
}

```

### Execution Agent: Broker-Ready Order Schema

The final agent generates executable orders through `EXECUTION_ORDER_PROMPT` (lines 152-165 in [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py)). This structured output aligns with standard brokerage API requirements:

```json
{
  "order_type": "market|limit|stop",
  "quantity": "int",
  "entry_price": "float",
  "stop_loss": "float",
  "take_profit": "float",
  "time_in_force": "str"
}

```

## Technical Implementation in the Source Code

Agent instantiation occurs in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py), where each worker is configured with `output_type="str"`. The system appends `_SYSTEM_SUFFIX` (current date/time) to system prompts, ensuring temporal context while maintaining JSON output constraints. According to the source, the pipeline flow executes sequentially:

1. Director creates the textual thesis
2. Quant Analyst receives the thesis and returns technical JSON
3. Risk Manager consumes both thesis and Quant output to produce risk JSON
4. Execution Agent synthesizes all prior outputs into the final order JSON

## Processing Structured Output in Practice

The `AutoHedge` class in [`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py) orchestrates the complete trading cycle. Configure `output_type="dict"` to receive parsed agent responses as dictionary keys containing JSON strings.

```python
from autohedge.main import AutoHedge
import json

# Initialize with dict output for structured access

auto = AutoHedge(output_type="dict")

# Execute full analysis pipeline

result = auto.run("Analyse AAPL and generate a trade plan.")

# Parse structured JSON outputs

quant_data = json.loads(result["quant"])
risk_data = json.loads(result["risk"])
exec_data = json.loads(result["execution"])

print("Technical Analysis:", quant_data)
print("Risk Assessment:", risk_data)
print("Execution Order:", exec_data)

```

The `auto.run()` method returns the conversation history containing the Director's thesis and each agent's structured JSON payload, enabling direct parsing into Python dictionaries for downstream automation.

## Summary

- AutoHedge implements a strict structured output protocol across three of four agents
- Schema definitions reside in [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py) with specific line references for each agent type
- Execution Agent produces brokerage-API-compatible order objects with type, quantity, pricing, and time-in-force fields
- Workers use `output_type="str"` configuration in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py) to ensure consistent JSON string delivery
- The pipeline processes sequentially: Director → Quant → Risk → Execution

## Frequently Asked Questions

### What is the structured output format for the Quant Analyst?

The Quant Analyst returns a JSON object containing `technical_score`, `volume_score`, `trend_strength`, `volatility`, `probability_score` (all float values between 0-1 where applicable), plus a nested `key_levels` object specifying `support`, `resistance`, and `pivot` price levels.

### Does the Director agent return structured data?

No. According to the `DIRECTOR_PROMPT` implementation in [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py), the Director returns free-form plain text representing the trading thesis. This unstructured output serves as contextual input for the three downstream agents that enforce JSON schemas.

### How does the structured output from AutoHedge agents enforce schema compliance?

Schema enforcement relies on explicit JSON examples embedded directly in prompt templates within [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py). The `Agent` definitions in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py) use `output_type="str"` to capture raw string responses, while the prompts themselves instruct the LLM to return only valid JSON matching the specified structure.

### Can the Execution Agent's output connect directly to live brokerage APIs?

Yes. The Execution Agent's structured output in [`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py) uses standard brokerage fields including `order_type`, `quantity`, `entry_price`, `stop_loss`, `take_profit`, and `time_in_force`, making it compatible with most trading APIs without additional transformation.