Fix: Reset memory for new problem #26
Open
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
In the current rollout pipeline, each worker process instantiates a single AgentFlowRollout and reuses the same Solver instance across many tasks. Since Solver holds a persistent Memory object, its internal state (especially actions and tool results) can persist across consecutive calls to Solver.solve() within the same worker.
This causes cross-task contamination: action steps and tool outputs from a previous sample may be mistakenly treated as context for the next sample, leading to unstable planning/verification behavior and incorrect final outputs.
Fix
This PR introduces an explicit reset API in Memory and ensures it is invoked at the start of each solve.
Add Memory.reset() to clear per-task state:
def reset(self):
self.query = None
self.files = []
self.actions = {}
Call self.memory.reset() at the beginning of Solver.solve() so every new task starts with a clean memory state:
Reset memory for new problem
self.memory.reset()
This enforces per-task isolation of memory while keeping the existing design (reusing Solver and other components within each worker process).