The log_states_dict is meant to accumulate per-ticker state logs.
Restoring it after propagate_portfolio() was discarding all the
detailed logs generated during the portfolio run.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Only include full tracebacks in error messages when debug=True.
In non-debug mode, return clean error messages without internal
implementation details.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
OSError only covers file I/O errors; json.dump can also raise
TypeError on non-serializable data. Use Exception to ensure logging
failures never discard analysis results.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Wrap _log_portfolio file I/O in try/except so a write failure
doesn't discard the analysis results
- Preserve and restore self.log_states_dict in propagate_portfolio()
alongside ticker and curr_state
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Required by the configurable log directory and config passthrough
from TradingAgentsGraph that were applied via GitHub suggestions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Preserve and restore self.ticker and self.curr_state in
propagate_portfolio() using try/finally to prevent side effects
- Use pathlib.Path for log file construction in _log_portfolio()
- Move traceback import to module level
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add PortfolioAnalyzer class that runs the full agent pipeline on multiple
stocks and produces a comparative KEEP/REDUCE/EXIT recommendation using
the deep thinking LLM. Includes per-ticker error handling, graceful
degradation on LLM failure, and result logging.
Addresses #60 and partially #406.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add effort parameter (high/medium/low) for Claude 4.5+ and 4.6 models,
consistent with OpenAI reasoning_effort and Google thinking_level.
Also add content normalization for Anthropic responses.
InvestDebateState was missing bull_history, bear_history, judge_decision.
RiskDebateState was missing aggressive_history, conservative_history,
neutral_history, latest_speaker, judge_decision. This caused KeyError
in _log_state() and reflection, especially with edge-case config values.
Prevents UnicodeEncodeError on Windows where the default encoding
(cp1252/gbk) cannot handle Unicode characters in LLM output.
Closes#77, closes#114, closes#126, closes#215, closes#332
- Add StatsCallbackHandler for tracking LLM calls, tool calls, and tokens
- Integrate callbacks into TradingAgentsGraph and all LLM clients
- Dynamic agent/report counts based on selected analysts
- Fix report completion counting (tied to agent completion)