Skip to content

fix(memory): keep future-resolved lessons out of point-in-time prompts - #1254

Open
hudsonwa wants to merge 1 commit into
TauricResearch:mainfrom
hudsonwa:fix/memory-lookahead-guard
Open

fix(memory): keep future-resolved lessons out of point-in-time prompts#1254
hudsonwa wants to merge 1 commit into
TauricResearch:mainfrom
hudsonwa:fix/memory-lookahead-guard

Conversation

@hudsonwa

@hudsonwa hudsonwa commented Aug 25, 2026

Copy link
Copy Markdown

Hi! First time contributing here, so thanks in advance for your patience with me.

Thank you as well to whoever wrote up #1251 so carefully; the file pointers made it genuinely easy to dig into, and out-of-order backtests are such an easy trap to fall into when you're iterating on dates.

I've had a go at a small fix. The idea: get_past_context() now takes an optional as_of_date, and any lesson whose outcome resolved after that date simply doesn't get shown to the agents. Same-day lessons stay in, since those are fair game. trading_graph.py passes the run's trade date through automatically, so nobody has to remember to opt in. And if you don't pass a date at all, nothing changes, existing behaviour stays exactly as it was.

Entries with unparseable dates are excluded rather than trusted, which seemed the safer side to land on, but happy to flip that if you'd prefer it to fail loud instead.

Tests: five new ones covering future exclusion, same-day inclusion, cross-ticker lessons, backwards compatibility, and malformed dates. Confirmed they fail against main without the change and pass with it, and the full suite is green (581 passed, 2 pre-existing skips).

Really enjoy what this project is building. Happy to tweak whatever doesn't fit the direction you want here. Cheers!

Decision-log reflections are grounded on realized outcomes and are
re-injected as past_context for the portfolio manager. Recall was keyed
only by ticker and recency, so a run for date D1 could be conditioned on
a lesson derived from an outcome resolved on D2 > D1. Out-of-order or
repeated backtests therefore leaked future information and could inflate
apparent alpha (TauricResearch#1251).

get_past_context() now accepts an optional as_of_date; entries whose
tag date is later (or unparseable) are excluded, and _run_graph() passes
the current trade_date through. Without as_of_date the behaviour is
unchanged.

Adds five regression tests covering future exclusion, same-day
inclusion, cross-ticker lessons, back-compat, and malformed dates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant