Skip to content

fix(agent): exclude prior-history tool messages from background review summary (salvage #14967)#15057

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-37dfb080
Apr 24, 2026
Merged

fix(agent): exclude prior-history tool messages from background review summary (salvage #14967)#15057
teknium1 merged 1 commit into
mainfrom
hermes/hermes-37dfb080

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #14967 by @luyao618 onto current main. Chosen over the parallel #14969 for robustness.

Closes #14944.

What this PR does

Stops the background memory/skill review from re-surfacing stale tool results from the prior conversation as if they just happened. After e.g. creating a cron reminder, subsequent 💾 background-review notifications would include Cron job '<name>' created. again on every run, even though cron wasn't touched.

How

The review agent forks with conversation_history=messages_snapshot, so its _session_messages contains inherited tool messages. The scan that builds the 💾 summary walked the whole list and treated historical tool successes as new review actions.

@luyao618 extracts the scan into a testable AIAgent._summarize_background_review_actions staticmethod that:

  • Records every tool_call_id in the snapshot and skips review messages whose tool_call_id matches
  • Falls back to content-equality for tool messages that lack a tool_call_id
  • Hardens the data.get('success') branch against non-dict JSON payloads (latent bug — bare-string/list content previously raised)

Why this over #14969

#14969 used a slice approach (_session_messages[len(snapshot):]) which is smaller but brittle: if any future init step reorders, filters, or deduplicates the history (compression, prefix-cache replay, future hydration logic), the slice boundary silently drifts and stale results leak through again. ID-based matching is immune. #14967 also matches the issue author's explicit suggested approach verbatim and fixes the non-dict JSON crash.

Validation

Before After
Stale 'Cron created' surfaced in later review yes skipped
New 'User profile updated' action surfaced yes yes
Non-dict JSON tool content (bare string/list) crash gracefully skipped

Co-authored-by: @luyao618

…w summary

Cherry-pick-of: 27b6a21 (PR #14967 by @luyao618)

Co-authored-by: luyao618 <364939526@qq.com>
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.

Background review notification includes stale tool results from conversation history

3 participants