fix(agent): skip snapshot messages when scanning bg review tool results#9696
Closed
john-livingston wants to merge 1 commit into
Closed
fix(agent): skip snapshot messages when scanning bg review tool results#9696john-livingston wants to merge 1 commit into
john-livingston wants to merge 1 commit into
Conversation
13 tasks
Collaborator
|
Likely duplicate of #15057 (merged) which fixed the same bug via ID-based matching. Verify this PR is still needed. |
Collaborator
|
Likely duplicate of #15057 (merged). |
Author
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.
Summary
_spawn_background_review()forks a review agent seeded with a snapshotof the current conversation (
messages_snapshot) plus a review prompt,then scans
_session_messagesfor tool results that indicate saves. Thebug: the scan iterated the entire
_session_messageslist, includingthe snapshot entries from the main conversation. Tool results in those
old messages (e.g. earlier memory/skill saves from a previous cycle)
were re-scanned and re-triggered the
💾save notification on everyreview cycle, even when the review agent saved nothing new.
Root cause:
_spawn_background_review()inrun_agent.pypassedthe full
_session_messagesto the action scan without accounting forthe
snapshot_lenprefix already present from the forked context.Fix: Slice
_session_messages[snapshot_len + 1:]so only messagesproduced by the review agent itself are scanned — skipping the
snapshot_lensnapshot entries and the +1 review prompt injected beforethe agent ran.
Changes
run_agent.py—_spawn_background_review(): recordsnapshot_len = len(messages_snapshot)before forking; slice_session_messagesbysnapshot_len + 1when collecting actions to notify onTest plan
not on repeat cycles when no new saves occurred
available in this environment)