fix(agent): exclude prior-history tool messages from background review summary#14967
Closed
luyao618 wants to merge 1 commit into
Closed
fix(agent): exclude prior-history tool messages from background review summary#14967luyao618 wants to merge 1 commit into
luyao618 wants to merge 1 commit into
Conversation
…w summary The background memory/skill review forks a new AIAgent with conversation_history=messages_snapshot. The forked agent's _session_messages therefore contains tool messages copied from the prior conversation. The post-review scan that builds the user-visible 💾 summary walked the entire _session_messages list, so historical successes (e.g. 'Cron job '...' created.') were re-surfaced as if they had just happened — sometimes multiple times across unrelated background-review runs. Extract the scan into a staticmethod and skip any tool message whose tool_call_id was already present in messages_snapshot, with a content-equality fallback for tool messages that lack one. Fixes NousResearch#14944
Collaborator
Contributor
|
Merged via #15057 — your commit was cherry-picked onto current main with your authorship preserved in Chose this implementation over the parallel #14969 because:
Thanks for the clean refactor and comprehensive tests. |
nekorytaylor666
pushed a commit
to nekorytaylor666/hermes-agent
that referenced
this pull request
Apr 24, 2026
…w summary Cherry-pick-of: 27b6a21 (PR NousResearch#14967 by @luyao618) Co-authored-by: luyao618 <364939526@qq.com>
justrhoto
pushed a commit
to justrhoto/hermes-agent
that referenced
this pull request
Apr 24, 2026
…w summary Cherry-pick-of: 27b6a21 (PR NousResearch#14967 by @luyao618) Co-authored-by: luyao618 <364939526@qq.com>
ulasbilgen
pushed a commit
to ulasbilgen/hermes-adhd-agent
that referenced
this pull request
May 1, 2026
…w summary Cherry-pick-of: 27b6a21 (PR NousResearch#14967 by @luyao618) Co-authored-by: luyao618 <364939526@qq.com>
aj-nt
pushed a commit
to aj-nt/hermes-agent
that referenced
this pull request
May 1, 2026
…w summary Cherry-pick-of: 27b6a21 (PR NousResearch#14967 by @luyao618) Co-authored-by: luyao618 <364939526@qq.com>
donald131
pushed a commit
to donald131/hermes-agent
that referenced
this pull request
May 2, 2026
…w summary Cherry-pick-of: 27b6a21 (PR NousResearch#14967 by @luyao618) Co-authored-by: luyao618 <364939526@qq.com>
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…w summary Cherry-pick-of: 27b6a21 (PR NousResearch#14967 by @luyao618) Co-authored-by: luyao618 <364939526@qq.com>
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…w summary Cherry-pick-of: 27b6a21 (PR NousResearch#14967 by @luyao618) Co-authored-by: luyao618 <364939526@qq.com>
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
…w summary Cherry-pick-of: 27b6a21 (PR NousResearch#14967 by @luyao618) Co-authored-by: luyao618 <364939526@qq.com>
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.
What does this PR do?
Fixes a bug where the background memory/skill review's user-visible summary (
💾 ...) re-surfaces stale tool successes from the prior conversation as if they had just happened._spawn_background_reviewforks a newAIAgentinitialized withconversation_history=messages_snapshot. The forked agent's_session_messagestherefore contains tool messages copied from the prior conversation. The post-review scan that builds the summary walked the entire_session_messageslist and reported every successful tool result it found, so historical actions (e.g. an earlierCron job '...' created.) were re-announced — sometimes repeatedly across unrelated background-review runs.Related Issue
Fixes #14944
Type of Change
Changes Made
AIAgent._summarize_background_review_actionsstaticmethod for testability.tool_call_idalready present inmessages_snapshotand skip review messages whosetool_call_idmatches — those are inherited from the prior conversation, not new actions.tool_call_id, fall back to content-equality against the prior snapshot's anonymous tool messages.datahandling so a non-dict JSON payload no longer raises in thedata.get("success")branch.How to Test
💾notification could includeCron job '<reminder>' created.even though no cron was created during that review. After the fix it doesn't.pytest tests/run_agent/test_background_review_summary.py -vpytest tests/run_agent/test_run_agent.py -qChecklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping