How the Director Agent Orchestrates Trading and Coordinates Agents in AutoHedge

The Director Agent serves as the central orchestrator in AutoHedge's multi-agent architecture, initiating market analysis and managing deterministic hand-offs to Quant, Risk, and Execution agents to transform high-level trading ideas into broker-ready orders.

In the AutoHedge open-source trading system, the Director Agent functions as the brain of the multi-agent workflow. According to the source code in The-Swarm-Corporation/AutoHedge, this specialized agent synthesizes market data, generates actionable trading theses, and coordinates specialized sub-agents through a structured hand-off mechanism that ensures deterministic execution from analysis to order placement.

The Director Agent's Core Responsibilities

The Director Agent operates as the entry point and traffic controller for AutoHedge's trading pipeline. It is defined in autohedge/workers.py where an Agent instance is created with a specific system prompt and hand-off configuration that establishes its authority over the workflow sequence.

Agent Definition and Hand-Off Configuration

In autohedge/workers.py (lines 80-86), the Director Agent is instantiated with a hand_offs parameter containing the other agents—Sentiment, Risk, Execution, and Quant. This configuration creates a deterministic execution chain where the Director maintains the authority to pass the trading thesis to specialized agents in sequence. The hand-off list ensures that context flows logically from market analysis through risk management to final execution without manual intervention.

System Prompt and Market Analysis Logic

The Director's decision-making capabilities are governed by the Director Prompt located in autohedge/prompts.py (lines 5-22). This system prompt instructs the agent to conduct comprehensive market analysis, identify relevant tickers using the Director Ticker Discovery Prompt (lines 95-102), and produce a concise trading thesis that serves as the foundation for downstream processing. The Director synthesizes macro-economic indicators, sector trends, and market sentiment to determine which securities warrant further analysis by the specialized pipeline.

The Sequential Trading Pipeline

Once the Director generates the initial thesis, it orchestrates a three-phase pipeline where each specialized agent builds upon the previous agent's output. This sequential hand-off mechanism ensures that quantitative analysis informs risk calculations, which in turn dictate execution parameters.

Phase 1: Quantitative Analysis Expansion

The workflow first hands the Director's thesis to the Quant-Analyst agent defined in autohedge/workers.py (lines 59-69). This agent receives the high-level thesis and enriches it with numeric indicators including technical scores, volume analysis, and trend strength measurements. The Quant agent transforms qualitative market observations into quantitative metrics that provide measurable entry signals.

Phase 2: Risk Management Evaluation

The enriched thesis then flows to the Risk-Manager agent (lines 35-45). This agent calculates critical risk parameters including position sizing limits, maximum draw-down thresholds, and overall risk scores. By evaluating the quantitative data through a risk lens, this phase ensures the trading strategy adheres to predefined risk management constraints before capital is committed.

Phase 3: Order Generation and Execution

Finally, the Execution-Agent (lines 47-57) receives the risk-adjusted parameters and generates a structured trade order. This output contains specific broker-ready instructions including order type (market, limit, or stop), precise quantity, entry and exit price levels, and time-in-force specifications. The Execution Agent finalizes the pipeline by producing actionable instructions that can interface directly with brokerage APIs.

Implementing the Director Workflow

The following examples demonstrate how to instantiate and run the Director Agent according to the AutoHedge source code.

To generate an initial market thesis:

from autohedge.workers import director_agent

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

To execute the complete end-to-end pipeline:

from autohedge.workers import director_agent

# Director creates thesis and automatically triggers hand-offs

director_output = director_agent.run(
    "Provide a trading thesis for the technology sector."
)

# Returns final execution order after Quant, Risk, and Execution processing

print("Execution Order:", director_output)

To customize the Director's analytical approach:

from autohedge.prompts import DIRECTOR_PROMPT
from autohedge.workers import director_agent

custom_prompt = DIRECTOR_PROMPT + "\nInclude macro-economic outlook."
director_agent.system_prompt = custom_prompt

Summary

  • The Director Agent defined in autohedge/workers.py (lines 80-86) serves as the central orchestrator with explicit hand-off configurations to sub-agents.
  • Market analysis is driven by the Director Prompt in autohedge/prompts.py, which guides ticker discovery and thesis generation.
  • The Quant-Analyst (lines 59-69) transforms qualitative theses into quantitative metrics with technical indicators.
  • The Risk-Manager (lines 35-45) applies position sizing and draw-down limits to create risk-adjusted parameters.
  • The Execution-Agent (lines 47-57) produces final trade orders with specific order types, prices, and quantities.
  • The hand-offs mechanism ensures deterministic, sequential processing where each agent builds upon the previous output.

Frequently Asked Questions

How does the Director Agent decide which agents to call and in what order?

The Director Agent's call sequence is determined by the hand_offs list defined in its initialization in autohedge/workers.py (lines 80-86). This configuration explicitly lists the Sentiment, Quant, Risk, and Execution agents, creating a deterministic pipeline where the Director passes context sequentially. The order is hardcoded in the agent definition, ensuring that quantitative analysis always precedes risk evaluation, which precedes order generation.

What specific data does the Director Agent include in its initial thesis?

According to autohedge/prompts.py (lines 5-22), the Director synthesizes a market overview that identifies relevant tickers, sector trends, and directional bias. The Director Ticker Discovery Prompt (lines 95-102) specifically guides the agent to select securities based on market conditions and expected trends. This thesis serves as the foundational context that downstream agents expand with technical indicators and risk parameters.

Can the Director Agent's system prompt be customized for different trading strategies?

Yes, the Director Agent's behavior can be modified by adjusting the DIRECTOR_PROMPT constant imported from autohedge/prompts.py. Since the agent is instantiated as a configurable Agent object in autohedge/workers.py, developers can override the system_prompt attribute to include additional instructions such as specific macro-economic factors, ESG criteria, or alternative asset classes, allowing the orchestration logic to adapt to various investment strategies.

How does the Director Agent maintain context across the multi-agent pipeline?

Context persistence is managed through the hand-off mechanism where each agent receives the complete output of the previous agent. When the Director initiates the workflow, it passes its thesis to the Quant agent, which appends its analysis and passes the combined context to the Risk agent. This sequential accumulation ensures that by the time the Execution-Agent (lines 47-57) generates the final order, it has access to the original market thesis, quantitative metrics, and risk calculations, maintaining a cohesive data lineage throughout the trading process.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →