| title | Agents and Runtime | |||
|---|---|---|---|---|
| description | How the multi-agent trading runtime is assembled and executed in the current application. | |||
| status | canonical | |||
| updated | 2026-04-03 | |||
| tags |
|
This document explains how the current strategy runner actually behaves.
The important files are:
cmd/tradingagent/runtime.gocmd/tradingagent/prod_strategy_runner.gointernal/agent/resolve_config.gointernal/agent/runner.gointernal/agent/strategy_config.go
A strategy run uses:
- a persisted
domain.Strategy - a typed
agent.StrategyConfigparsed from the strategy’s JSONconfig - system-level defaults from the settings/bootstrap layer
- hardcoded fallbacks from
ResolveConfig
The resulting run is then executed by the production strategy runner.
market_analystfundamentals_analystnews_analystsocial_media_analyst
bull_researcherbear_researcherresearch_manager/ invest judge role
trader
aggressive_analystconservative_analystneutral_analystrisk_manager
The runtime follows these conceptual phases:
analysis -> research_debate -> trading -> risk_debate
The runner seeds market context, then executes the enabled analysts in parallel.
Inputs may include:
- OHLCV bars and indicators
- fundamentals
- recent news
- social sentiment snapshots
Bull and bear roles argue over the evidence. A manager/judge role synthesizes the result into an investment plan.
The trader converts the investment plan into a concrete trade plan:
- side
- sizing
- stop-loss framing
- take-profit framing
- execution details
The aggressive, conservative, and neutral roles debate the trade plan. The risk manager emits the final actionable signal such as buy, sell, or hold plus confidence.
The signal does not directly guarantee execution. The hard risk engine and order-management layer still apply:
- kill switch
- circuit breaker
- position limits
- exposure caps
- live vs paper execution routing
agent.ResolveConfig merges values in this order:
- strategy config overrides
- global settings
- hardcoded defaults
Current hardcoded defaults:
| Field | Default |
|---|---|
| provider | openai |
| deep think model | gpt-5.2 |
| quick think model | gpt-5-mini |
| debate rounds | 3 |
| analysis timeout | 30 seconds |
| debate timeout | 60 seconds |
| position size | 5.0 percent |
| stop-loss multiplier | 1.5 |
| take-profit multiplier | 2.0 |
| minimum confidence | 0.65 |
Strategies can restrict which analyst roles run via analyst_selection.
Semantics:
nilanalyst selection means all analysts are enabled- a non-empty list means only those roles run
This is one of the most useful ways to tune cost and latency per strategy.
Strategies can replace the default system prompt for individual roles via prompt_overrides.
Practical caution:
- prompt overrides are powerful but easy to abuse
- treat them as precision overrides, not a place to dump strategy prose
The runtime supports these provider names:
openaianthropicgoogleopenrouterxaiollama
Provider wiring details:
openrouterandxaiare treated as OpenAI-compatible transports in the production runner- the strategy config validator enforces provider/model allowlists for some providers and looser validation for others
Before agent execution, the production runner loads initial state from the data service.
That seed can include:
- market bars plus indicators
- fundamentals
- news articles
- latest social sentiment snapshot
The completeness of the seed depends on provider availability for the selected market type.
The runtime uses phase-specific timeouts from resolved config.
Important caveat:
- the current runtime does not enforce a meaningful whole-pipeline timeout; only phase-level limits are effectively applied
The production strategy runner chooses brokers roughly as follows:
- paper stock:
- Alpaca paper when configured and allowed
- otherwise local paper broker
- paper crypto:
- Binance paper/testnet when configured and allowed
- otherwise local paper broker
- live stock:
- Alpaca when live trading is enabled and configured
- live crypto:
- Binance when live trading is enabled and configured
- live polymarket:
- not yet presented as a fully supported path in the main runner
A run can produce and persist:
- pipeline run records
- agent decisions
- events
- snapshots
- orders
- positions
- trades
- memories
- audit records
- The repo still contains unresolved merge conflicts in some runtime-related files.
- The newer runtime path is the production truth; older pipeline abstractions still exist and are useful context, but they are not the whole story.
- Settings-driven config changes are not durable across restart.