TradingAgents/tradingagents/agents/utils
ahmet guzererler 2145b04318
fix: graceful LLM 404 handling + per-tier fallback model config (#108)
* fix: per-tier fallback LLM for provider 404/policy errors

- tool_runner: catch status_code==404 from chain.invoke(), re-raise as
  RuntimeError with actionable message (OpenRouter privacy URL + env var hint)
- langgraph_engine: wrap astream_events in try/except, detect policy errors
  and re-raise with model/provider context
- langgraph_engine: _run_one_ticker distinguishes policy 404s (logger.error,
  no traceback) from real bugs (logger.exception with traceback); if fallback
  is configured, rebuilds pipeline with fallback model tier and retries
- langgraph_engine: add _is_policy_error() and _build_fallback_config() helpers
- default_config: add quick/mid/deep_think_fallback_llm + _provider keys
  (TRADINGAGENTS_QUICK_THINK_FALLBACK_LLM etc.)
- .env.example: document new fallback env vars

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: ADR 017 LLM policy fallback, correct ADR 016 findings, update CLAUDE.md

- docs/agent/decisions/017: add ADR for per-tier LLM fallback design decision
- docs/agent/decisions/016: correct 3 inaccurate review findings — list_pm_decisions
  ObjectId projection, created_at datetime type, and base_dir pointer handling are
  all already correctly implemented in PR#106
- CLAUDE.md: add Per-Tier Fallback LLM section and _is_policy_error critical pattern
- CURRENT_STATE.md: update milestone and recent progress for PR#106/107/108 merges

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 11:19:08 +01:00
..
agent_states.py feat: medium-term positioning upgrade (debate rounds, TTM, peer comparison, macro regime) (#14) 2026-03-17 22:27:40 +01:00
agent_utils.py Parallel pre-fetch for analyst agents to reduce LLM round-trips 2026-03-23 21:08:15 +00:00
core_stock_tools.py minor fix 2025-09-26 23:25:33 +08:00
fundamental_data_tools.py feat: medium-term positioning upgrade (debate rounds, TTM, peer comparison, macro regime) (#14) 2026-03-17 22:27:40 +01:00
json_utils.py perf: pre-compile regex patterns in extract_json util 2026-03-21 01:34:43 +00:00
memory.py feat: add multi-provider LLM support with thinking configurations 2026-02-03 22:27:20 +00:00
news_data_tools.py fix: improve data vendor implementations and tool signatures 2026-02-03 22:27:20 +00:00
portfolio_tools.py feat: add portfolio risk metrics module and LangChain agent tools 2026-03-20 14:42:43 +00:00
scanner_states.py feat(scanner): Finviz smart money scanner + Golden Overlap strategy 2026-03-24 16:03:17 +01:00
scanner_tools.py feat(scanner): Finviz smart money scanner + Golden Overlap strategy 2026-03-24 16:03:17 +01:00
technical_indicators_tools.py Sync fork with upstream TauricResearch/TradingAgents (v0.2.1) (#12) 2026-03-18 07:00:37 +01:00
tool_runner.py fix: graceful LLM 404 handling + per-tier fallback model config (#108) 2026-03-25 11:19:08 +01:00