Skip to content

Memory and reflection: cheatsheet

For education only. Multi-agent architecture taught via stock analysis; not investment, financial, or trading advice.

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.)

MomentWhenWhat happensModel used?
RecordEnd of a runThe decision is written to the logbook and marked pending (not yet judged)No
ReflectStart of the next same-company runThe earlier pending entry is resolved against the real outcome, and a short reflection is writtenYes (the cheaper model)

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.

  • 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.

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.

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.

  1. Record the decision when it is made; mark it not-yet-judged; spend no model on it.
  2. Wait. Reflect only once the real outcome is visible.
  3. Ground the reflection in what actually happened, ideally against a baseline, not in the system’s own confidence.
  4. Keep the lesson short, and feed it back to the step that makes the decision.
  • 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.
  • 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.