Memory and reflection: cheatsheet
For education only. Multi-agent architecture taught via stock analysis; not investment, financial, or trading advice.
The one idea
Section titled “The one idea”A good system records what it decided, then reflects on it once the outcome is known, and feeds the lesson back to the next decision. (Anchored to the TradingAgents framework, frozen snapshot 7e9e7b8; memory in agents/utils/memory.py, reflection in graph/reflection.py, the loop in graph/trading_graph.py.)
Two moments, kept apart in time
Section titled “Two moments, kept apart in time”| Moment | When | What happens | Model used? |
|---|---|---|---|
| Record | End of a run | The decision is written to the logbook and marked pending (not yet judged) | No |
| Reflect | Start of the next same-company run | The earlier pending entry is resolved against the real outcome, and a short reflection is written | Yes (the cheaper model) |
The logbook entry
Section titled “The logbook entry”Each entry begins with a tag. While the outcome is unknown it ends in one telling word:
[ trade_date | ticker | stance | pending ]pending is the placeholder for hindsight. It is replaced once the outcome is known and the reflection is written.
How reflection is grounded
Section titled “How reflection is grounded”- The system looks at what actually happened over the following days (five, by default).
- It compares that against a baseline: how a broad market slice moved over the same days (the framework uses the S&P 500). Beating or trailing a simple baseline is a fairer test than a raw up-or-down.
- The reflection prompt asks for a few plain sentences: was the call right, what held or failed, one concrete lesson for next time. Short on purpose, so it can be re-read later.
Where memory goes
Section titled “Where memory goes”The accumulated history is injected at the start of a run, and only the final gate (the portfolio manager, on the more capable model) reads it. Memory lands where the system commits.
How to follow along
Section titled “How to follow along”Read it free in your browser at github.com/TauricResearch/TradingAgents (pinned snapshot). No account, no Git, no programming knowledge needed. The short code 7e9e7b8 marks one frozen version, so the lessons match what you see.
Build your own (the transferable pattern)
Section titled “Build your own (the transferable pattern)”- Record the decision when it is made; mark it not-yet-judged; spend no model on it.
- Wait. Reflect only once the real outcome is visible.
- Ground the reflection in what actually happened, ideally against a baseline, not in the system’s own confidence.
- Keep the lesson short, and feed it back to the step that makes the decision.
Pitfalls to dodge
Section titled “Pitfalls to dodge”- Grading the decision the moment you make it (no outcome yet, so it is just confidence restated).
- Reflecting on a feeling instead of a result (it rationalizes instead of learning).
- Writing memory too long or raw to re-read, or never feeding it back in.
Words to use precisely
Section titled “Words to use precisely”- Pending: a recorded decision whose outcome is not yet known.
- Reflection: the short, hindsight lesson written once the outcome is known.
- Baseline: what would have happened anyway (here, a broad market slice), used to make the test fair.