Skip to content

fix(agent): skip snapshot messages when scanning bg review tool results#9696

Closed
john-livingston wants to merge 1 commit into
NousResearch:mainfrom
john-livingston:fix/bg-review-snapshot-scan
Closed

fix(agent): skip snapshot messages when scanning bg review tool results#9696
john-livingston wants to merge 1 commit into
NousResearch:mainfrom
john-livingston:fix/bg-review-snapshot-scan

Conversation

@john-livingston

Copy link
Copy Markdown

Summary

_spawn_background_review() forks a review agent seeded with a snapshot
of the current conversation (messages_snapshot) plus a review prompt,
then scans _session_messages for tool results that indicate saves. The
bug: the scan iterated the entire _session_messages list, including
the 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 every
review cycle, even when the review agent saved nothing new.

Root cause: _spawn_background_review() in run_agent.py passed
the full _session_messages to the action scan without accounting for
the snapshot_len prefix already present from the forked context.

Fix: Slice _session_messages[snapshot_len + 1:] so only messages
produced by the review agent itself are scanned — skipping the
snapshot_len snapshot entries and the +1 review prompt injected before
the agent ran.

Changes

  • run_agent.py_spawn_background_review(): record snapshot_len = len(messages_snapshot) before forking; slice _session_messages by
    snapshot_len + 1 when collecting actions to notify on

Test plan

  • Manually verified: save notification fires once per genuine save cycle,
    not on repeat cycles when no new saves occurred
  • No automated tests added (existing suite requires dependencies not
    available in this environment)

@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #15057 (merged) which fixed the same bug via ID-based matching. Verify this PR is still needed.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #15057 (merged).

@john-livingston

Copy link
Copy Markdown
Author

Closing in favour of #15057 (merged 2026-04-24) which fixes the same bug more robustly via ID-based matching rather than a slice boundary. The ID-based approach is immune to future history reordering/compression. Thanks to @luyao618 for the thorough fix and tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants