mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-06-16 21:06:15 +03:00
fix(graph): resolve instrument identity to stop wrong-company hallucination
Agents had no ground-truth ticker→company mapping, so the market analyst could pattern-match a price chart to the wrong company (e.g. TOTDY read as "TotalEnergies"), and every downstream agent inherited the bad framing. Resolve identity once at run start via a cached, fail-open yfinance lookup and inject company/sector/exchange into the shared instrument context that all twelve agents consume, with an explicit do-not-substitute instruction. Resolution runs on both the propagate() and CLI entry points. Also replaces the bare "Continue" message-clear placeholder, which some OpenAI-compatible providers interpreted as the user task, with a context-anchored placeholder carrying the resolved identity and date. #814 #888
This commit is contained in:
@@ -1098,11 +1098,18 @@ def run_analysis(checkpoint: bool = False):
|
||||
)
|
||||
update_display(layout, spinner_text, stats_handler=stats_handler, start_time=start_time)
|
||||
|
||||
# Initialize state and get graph args with callbacks
|
||||
# Initialize state and get graph args with callbacks.
|
||||
# Resolve the instrument identity once here so all agents anchor to
|
||||
# the real company (#814); the CLI builds state directly rather than
|
||||
# going through propagate(), so this must happen on the CLI path too.
|
||||
instrument_context = graph.resolve_instrument_context(
|
||||
selections["ticker"], selections["asset_type"]
|
||||
)
|
||||
init_agent_state = graph.propagator.create_initial_state(
|
||||
selections["ticker"],
|
||||
selections["analysis_date"],
|
||||
asset_type=selections["asset_type"],
|
||||
instrument_context=instrument_context,
|
||||
)
|
||||
# Pass callbacks to graph config for tool execution tracking
|
||||
# (LLM tracking is handled separately via LLM constructor)
|
||||
|
||||
Reference in New Issue
Block a user