fix(cli): read and write the decision log on the CLI path - #1332
Closed
newnewself wants to merge 1 commit into
Closed
newnewself wants to merge 1 commit into
newnewself wants to merge 1 commit into
Conversation
The memory log was only touched inside propagate()/_run_graph(), but the CLI builds its own state and streams the graph directly, so a normal CLI run never wrote a decision, never settled pending entries, and never injected prior lessons into the Portfolio Manager — the README's "always on" decision log was dead on the primary entry point. Share the lifecycle: TradingAgentsGraph gains prepare_memory_context() and record_decision(), propagate() uses them, and run_analysis() calls them around the stream. A partial stream writes nothing and keeps its checkpoint. Same shape as the TauricResearch#1249 fix that made --checkpoint work on the CLI.
newnewself
force-pushed
the
fix/cli-decision-log
branch
from
September 12, 2026 08:54
6e87d43 to
65d3c7a
Compare
Member
|
Thanks @newnewself. Implemented in 4a9f196: the CLI and propagate() share one decision-log path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The persistent decision log is only touched inside
propagate()→_run_graph(). The CLI (analyze→run_analysis) builds its own initial state and streamsgraph.graphdirectly, so on a normaltradingagentsrun:past_context.README: "The decision log is always on. Each completed run appends its decision to
~/.tradingagents/memory/trading_memory.md. On the next run for the same ticker, TradingAgents fetches the realised return … and injects the most recent same-ticker decisions plus recent cross-ticker lessons into the Portfolio Manager prompt." None of that happens on the primary entry point today.This is the same shape as the
--checkpointbug fixed in #1249: lifecycle logic that lived only inpropagate()was a no-op on the CLI. That fix introducedbegin_checkpoint/checkpoint_input/end_checkpointso both paths share the lifecycle; this PR does the same for the memory log.Fix
TradingAgentsGraph.prepare_memory_context(ticker, date)— settles pending entries for the ticker and returns the date-gated past-context block (Decision-log lessons lack a point-in-time guard — possible lookahead in backtests #1251 semantics preserved).TradingAgentsGraph.record_decision(ticker, date, final_state)— appends the decision; a run that produced no final decision (interrupted stream) is skipped with a warning instead of raising.propagate()now uses both;run_analysis()callsprepare_memory_contextbefore building state andrecord_decisionafter a clean stream. A mid-stream failure records nothing, so the checkpoint is kept for resume and no partial decision is logged.Tests
New
tests/test_cli_decision_log.py:run_analysisrun with a fake graph and patched UI asserts the initial state receivespast_contextand the completed run is recorded.Full suite: 658 passed, 1 skipped.