# AutoHedge Architecture: The 5 Specialized Trading Agents Explained

> Discover the AutoHedge architecture's 5 specialized trading agents. Learn how the Trading Director, Sentiment Agent, Quant Analyst, Risk Manager, and Execution Agent collaborate to execute trades.

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

---

**The AutoHedge architecture employs five specialized LLM agents—a Trading Director, Sentiment Agent, Quant Analyst, Risk Manager, and Execution Agent—that collaborate sequentially to transform high-level market tasks into structured trade orders.**

The AutoHedge architecture in The-Swarm-Corporation/AutoHedge repository implements a modular swarm intelligence system where each agent owns a distinct responsibility in the trading pipeline. This multi-agent design separates concerns across sentiment analysis, quantitative modeling, risk assessment, and order execution, enabling extensible automated trading workflows. Each agent communicates through well-defined prompts configured in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py) and shares a unified system-wide date-time context.

## The Five Core Agents

### Trading Director (director_agent)

The **Trading Director** serves as the central orchestrator that manages the entire workflow from task ingestion to final execution. Implemented as `director_agent` in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py) using `DIRECTOR_PROMPT`, this agent parses user requests, discovers relevant tickers via `DIRECTOR_TICKER_DISCOVERY_PROMPT`, and coordinates hand-offs to specialist agents through the `ALL_AGENTS` list. It maintains state across the pipeline, ensuring that sentiment data, quantitative scores, and risk assessments flow sequentially toward the final order generation.

### Sentiment Agent (sentiment_agent)

The **Sentiment Agent** extracts and scores market sentiment from news, social media, and analyst commentary. Defined in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py) as `sentiment_agent` with the `SENTIMENT_PROMPT` plus a system date suffix, this specialist returns a normalized sentiment score between 0 and 1 alongside thematic insights. It utilizes the [`exa_search_tool.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/exa_search_tool.py) module to fetch real-time articles, anchoring its analysis to the current market moment through the shared `_SYSTEM_SUFFIX` context.

### Quant Analyst (quant_agent)

The **Quant Analyst** performs rigorous quantitative analysis on specific tickers based on the Director’s thesis. Instantiated as `quant_agent` using `QUANT_PROMPT`, this agent delivers technical scores, volume analysis, trend identification, volatility metrics, and probability assessments. It also calculates key support and resistance levels required for entry and exit planning, transforming qualitative market theses into numeric decision frameworks.

### Risk Manager (risk_agent)

The **Risk Manager** evaluates trade-level risk exposure and position sizing. Configured as `risk_agent` with a custom prompt that expands the generic `RISK_PROMPT` and appends the system date suffix, this agent suggests specific position sizes, estimates maximum drawdown potential, gauges overall market-risk exposure, and produces a composite risk score. It acts as a gatekeeper, ensuring that quantitative opportunities align with predefined risk tolerances before execution.

### Execution Agent (execution_agent)

The **Execution Agent** translates approved trade concepts into concrete broker-ready orders. Created as `execution_agent` using `EXECUTION_PROMPT`, this final specialist generates structured order specifications including order type, quantity, entry and exit prices, stop-loss levels, take-profit targets, and time-in-force parameters. It represents the terminal node in the AutoHedge architecture, outputting actionable instructions that can interface directly with trading APIs.

## The Trading Workflow Pipeline

The AutoHedge architecture follows a strict six-stage pipeline orchestrated by the Director:

1. **Task Ingestion** – The Director receives high-level requests (e.g., "Provide a market thesis for today") and parses intent using its system prompt.

2. **Ticker Discovery** – The Director invokes `DIRECTOR_TICKER_DISCOVERY_PROMPT` to identify relevant symbols for analysis.

3. **Sentiment Analysis** – For each discovered ticker, the Director forwards the symbol to the Sentiment Agent, which returns sentiment metrics and confidence scores.

4. **Quantitative Analysis** – The Director passes the aggregated thesis and sentiment data to the Quant Analyst, which produces numeric scores, trend directions, and key price levels.

5. **Risk Assessment** – The Risk Manager consumes the quantitative output to calculate position sizing, drawdown estimates, and risk scores, vetoing trades that exceed thresholds.

6. **Trade Execution** – Finally, the Execution Agent formats a structured order object ready for broker integration, completing the autonomous cycle.

All agents share the same **system-wide date-time context** (`_SYSTEM_SUFFIX`) defined in the prompt configuration, ensuring temporal coherence across the swarm.

## Implementing the Agent Swarm

### Running the Complete Pipeline

Invoke the Director to trigger the full chain of hand-offs defined in [`workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/workers.py):

```python
from autohedge.workers import director_agent

# One-line entry point – the Director orchestrates everything.

output = director_agent.run(
    "Analyze the stock market and provide a thesis on the overall market position and expected trends."
)
print(output)

```

### Direct Specialist Access

Call individual agents for targeted analysis without the full orchestration:

**Sentiment Analysis Only:**

```python
from autohedge.workers import sentiment_agent

sentiment = sentiment_agent.run(
    "Ticker: AAPL\nProvide sentiment analysis for the last 24h."
)
print(sentiment)

```

**Custom Risk Assessment:**

```python
from autohedge.workers import risk_agent

risk_info = risk_agent.run(
    "Stock: TSLA\nThesis: Long on breakout\nQuant Analysis: {\"technical_score\":0.85,\"volume_score\":0.7}"
)
print(risk_info)

```

## Key Source Files

- **[`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py)** – Declares all agents, their prompts (including `SENTIMENT_PROMPT`, `QUANT_PROMPT`, `RISK_PROMPT`, `EXECUTION_PROMPT`, and `DIRECTOR_PROMPT`), model configurations, and the `ALL_AGENTS` hand-off wiring.
- **[`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py)** – Stores the full text of every system prompt used by the agent swarm.
- **[`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py)** – Entry point that imports the Director and initializes the trading cycle.
- **[`autohedge/tools/exa_search_tool.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/tools/exa_search_tool.py)** – Provides the web-search capability used by the Sentiment Agent to fetch latest market articles.
- **[`autohedge/cli.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/cli.py)** – Command-line interface wrapper for launching the system.

The modular design allows you to add, remove, or swap agents by updating the hand-offs list in [`workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/workers.py), making the AutoHedge architecture extensible for new data sources or alternative trading strategies.

## Summary

- **Trading Director** orchestrates the six-stage workflow and manages agent hand-offs through `ALL_AGENTS` in [`workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/workers.py).
- **Sentiment Agent** analyzes market mood using `SENTIMENT_PROMPT` and real-time web search tools.
- **Quant Analyst** generates technical scores and price levels via `QUANT_PROMPT`.
- **Risk Manager** calculates position sizing and drawdown risks using an expanded `RISK_PROMPT`.
- **Execution Agent** outputs broker-ready orders structured by `EXECUTION_PROMPT`.
- All agents share the `_SYSTEM_SUFFIX` context to maintain temporal alignment on market data.

## Frequently Asked Questions

### How does the Trading Director coordinate between agents?

The Trading Director maintains a hand-off list (`ALL_AGENTS`) in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py) that defines the sequence of specialist invocations. After parsing the initial task and discovering tickers, it explicitly passes context to each agent in order—first Sentiment, then Quant Analyst, then Risk Manager—collecting outputs before finally commanding the Execution Agent to generate orders.

### Can I run individual agents without the full AutoHedge pipeline?

Yes, each agent is instantiated as an independent callable in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py). You can import `sentiment_agent`, `quant_agent`, `risk_agent`, or `execution_agent` directly and invoke their `.run()` methods with specific prompts, bypassing the Director's orchestration logic entirely.

### What determines the risk thresholds in the Risk Manager?

The Risk Manager uses the `RISK_PROMPT` template combined with real-time quantitative data provided by the Quant Analyst. The prompt instructs the LLM to evaluate maximum drawdown, market-risk exposure, and position sizing based on the specific ticker, current market conditions (via `_SYSTEM_SUFFIX`), and the thesis generated by the Director.

### Where is the system date context defined for all agents?

The shared date-time context is defined as `_SYSTEM_SUFFIX` in the prompt configuration within [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py). This suffix is appended to the system prompts of the Sentiment Agent and Risk Manager (and available to others), ensuring all agents reference the same current market date and time in their analyses.