How to Format the Risk Assessment Prompt for an AutoHedge Agent

To format the Risk Assessment Prompt for an AutoHedge agent, populate the RISK_ASSESSMENT_PROMPT template from autohedge/prompts.py with the stock ticker, trading thesis, and quantitative analysis data using Python's str.format() method.

The AutoHedge repository by The-Swarm-Corporation orchestrates multi-agent AI workflows for algorithmic trading. Formatting the Risk Assessment Prompt correctly ensures the Risk Assessment Agent receives the precise context needed to evaluate market exposure and position sizing. This template serves as the critical bridge between quantitative analysis generated by the Quant Agent and the final execution decisions made by the Execution Agent.

Locating the RISK_ASSESSMENT_PROMPT Template

The Risk Assessment Prompt template is defined in autohedge/prompts.py at lines 141-151 as a constant named RISK_ASSESSMENT_PROMPT. This Python multi-line string uses named placeholders for dynamic data injection at runtime. According to the AutoHedge source code, the template is designed to accept three specific keyword arguments that provide comprehensive trading context to the underlying language model.

Required Placeholders and Data Types

When formatting the prompt, you must supply values for three placeholders using str.format(key=value):

  • {stock} — The ticker symbol of the security being evaluated (e.g., AAPL, TSLA, MSFT).
  • {thesis} — The high-level trading thesis generated by the Director Agent, containing the strategic rationale for the trade.
  • {quant_analysis} — A JSON-formatted string containing quantitative metrics produced by the Quant Agent via the QUANT_ANALYSIS_PROMPT template.

The quant_analysis parameter typically includes fields such as technical_score, volume_score, trend_strength, volatility, and key_levels. This structured data enables the Risk Assessment Agent to perform automated risk calculations based on concrete market indicators.

Code Example: Populating the Template

The following example demonstrates how to import and format the Risk Assessment Prompt with realistic trading data:

from autohedge.prompts import RISK_ASSESSMENT_PROMPT

# Data generated by upstream agents (Director and Quant)

stock = "AAPL"
thesis = "Long on AAPL due to strong earnings beat."
quant_analysis = """{
    "technical_score": 0.87,
    "volume_score": 0.73,
    "trend_strength": 0.91,
    "volatility": 0.22,
    "probability_score": 0.78,
    "key_levels": {"support": 150.0, "resistance": 165.0, "pivot": 157.5}
}"""

# Format the prompt using Python's string formatting

formatted_prompt = RISK_ASSESSMENT_PROMPT.format(
    stock=stock,
    thesis=thesis,
    quant_analysis=quant_analysis,
)

print(formatted_prompt)

Output:

Stock: AAPL
Thesis: Long on AAPL due to strong earnings beat.
Quant Analysis: {
    "technical_score": 0.87,
    "volume_score": 0.73,
    "trend_strength": 0.91,
    "volatility": 0.22,
    "probability_score": 0.78,
    "key_levels": {"support": 150.0, "resistance": 165.0, "pivot": 157.5}
}

Provide risk assessment including:
1. Recommended position size
2. Maximum drawdown risk
3. Market risk exposure
4. Overall risk score

Expected Output Structure

The formatted prompt explicitly instructs the Risk Assessment Agent to return four specific risk metrics. As implemented in autohedge/workers.py, the system expects the LLM response to contain:

  1. Recommended position size — The optimal capital allocation for this trade.
  2. Maximum drawdown risk — The potential peak-to-trough decline percentage.
  3. Market risk exposure — Systematic risk factors affecting the position.
  4. Overall risk score — A normalized risk rating (typically 0.0 to 1.0).

This structured output expectation ensures that downstream parsing logic in autohedge/workers.py can reliably extract risk parameters and pass them to the Execution Agent via the EXECUTION_ORDER_PROMPT.

Integration with the AutoHedge Agent Workflow

Understanding the prompt format requires context of the end-to-end data flow. The Risk Assessment Prompt acts as the third stage in a four-agent pipeline:

  • Director Agent generates the initial {thesis} based on market conditions.
  • Quant Agent produces the {quant_analysis} JSON using QUANT_ANALYSIS_PROMPT.
  • Risk Assessment Agent consumes the formatted RISK_ASSESSMENT_PROMPT to generate risk metrics.
  • Execution Agent receives the finalized risk report through EXECUTION_ORDER_PROMPT to determine order parameters.

This modular architecture isolates responsibilities while maintaining strict data contracts between agents. By adhering to the RISK_ASSESSMENT_PROMPT template structure, developers ensure that the Risk Assessment Agent receives consistent, machine-readable instructions that align with the overall AutoHedge orchestration logic defined in autohedge/main.py.

Summary

  • The Risk Assessment Prompt template resides in autohedge/prompts.py (lines 141-151) as the constant RISK_ASSESSMENT_PROMPT.
  • Formatting requires three parameters: {stock}, {thesis}, and {quant_analysis} passed via Python's str.format() method.
  • The prompt instructs the LLM to return four specific risk metrics: position size, drawdown risk, market exposure, and overall risk score.
  • Proper formatting ensures seamless integration between the Quant Agent, Risk Assessment Agent, and Execution Agent within the AutoHedge workflow.

Frequently Asked Questions

Where is the Risk Assessment Prompt defined in the AutoHedge codebase?

The Risk Assessment Prompt is defined in autohedge/prompts.py at lines 141-151 as the Python constant RISK_ASSESSMENT_PROMPT. This file contains all prompt templates used across the various agents in the system, including DIRECTOR_PROMPT, QUANT_ANALYSIS_PROMPT, and EXECUTION_ORDER_PROMPT.

What data does the Risk Assessment Prompt template require?

The template requires three keyword arguments: stock (the ticker symbol), thesis (the trading strategy rationale), and quant_analysis (JSON-formatted quantitative metrics). These values are typically generated dynamically by the Director Agent and Quant Agent during the trading workflow execution.

How does the formatted prompt integrate with the Risk Assessment Agent?

After formatting via str.format(), the resulting string is sent to the Large Language Model (LLM) backing the Risk Assessment Agent. The agent parses this natural-language request and returns a structured risk report containing the four required metrics, which autohedge/workers.py then processes for the Execution Agent.

Can I customize the Risk Assessment Prompt template?

Yes, developers can modify the RISK_ASSESSMENT_PROMPT constant in autohedge/prompts.py, but must preserve the four output expectations (position size, drawdown risk, market exposure, overall risk score) to ensure compatibility with the parsing logic in autohedge/workers.py. Changes to input placeholders require corresponding updates to the agent orchestration code in autohedge/main.py.

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 →