hermes - ✅(Solved) Fix [Bug]: Memory/Skill Review Issues in run_agent [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Additional Logs / Traceback (optional)

Root Cause

Root Cause Analysis (optional)

Fix Action

Fixed

PR fix notes

PR #13092: fix(run_agent): prevent duplicate memory reviews,implement conditional nudge resets: (#13092)

Description (problem / solution / changelog)

Related Issue

Fixes #13075

What does this PR do?

This PR improves the memory/skill nudge trigger logic by:

  1. Preventing Duplicate Memory Reviews: By moving the _should_review_memory check to occur after tool calls, we effectively prevent redundant memory reviews. Note: Previously, if _should_review_memory was true while a memory tool was executed in the loop, a duplicate review would still trigger after the loop despite the counter reset.

  2. Implementing Conditional Counter Resets: Nudge counters for skills and memory are now reset only upon the confirmed initiation of the background review process. Note: Previously, nudge counters were reset immediately upon reaching the interval threshold. However, if the review operation was not executed—due to an empty final_response or an interruption—the accumulated progress was lost, forcing a restart of the counter accumulation.

This approach is correct because it ensures:

  1. No duplicate memory reviews occur.
  2. Nudge opportunities aren't lost due to interruptions or conversation failures—no need to restart accumulation from scratch.
  3. The code has clearer, more intuitive semantics.
  4. Memory and skill nudge behavior is consistent.

Type of Change

  • [✅] 🐛 Bug fix (non-breaking change that fixes an issue)
  • [✅] ✅ Tests (adding or improving test coverage)

Changes Made

  • run_agent.py: Moved memory nudge trigger check from conversation start to end
  • run_agent.py: Moved memory/skill counter reset logic to only happen when background review is actually spawned Aligned memory nudge logic with skill nudge logic for consistency
  • tests/run_agent/test_memory_skill_nudge_trigger.py: Added comprehensive unit tests for the new logic

How to Test

  1. Normal nudge trigger test :
    • Set _memory_nudge_interval = 2 (in code or via config)
    • Have 2 conversation turns
    • Verify memory nudge triggers after the second turn
  2. User-initiated memory tool test :
    • Set _memory_nudge_interval = 2
    • Have 1 conversation turn (counter = 1)
    • In the second turn, manually call the memory tool (counter resets to 0)
    • Verify no duplicate memory nudge is triggered
  3. Conversation interruption test :
    • Set _memory_nudge_interval = 2
    • Have 1 conversation turn (counter = 1)
    • Start a second turn but interrupt/fail it
    • Verify the counter remains intact and nudge triggers on next successful turn

Checklist

Code

Documentation & Housekeeping

  • [N/A] I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • [N/A] I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • [N/A] I've updated [[CONTRIBUTING.md](http://contributing.md/)](http://contributing.md/) or [[AGENTS.md](http://agents.md/)](http://agents.md/) if I changed architecture or workflows — or N/A
  • [N/A] I've considered cross-platform impact (Windows, macOS) per the [compatibility guide]([hermes-agent/CONTRIBUTING.md at main · NousResearch/hermes-agent](hermes-agent/CONTRIBUTING.md at main · NousResearch/hermes-agent)) — or N/A
  • [N/A] I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Changed files

  • run_agent.py (modified, +14/-8)
  • tests/run_agent/test_memory_skill_nudge_trigger.py (added, +175/-0)

Code Example

N/A

---
RAW_BUFFERClick to expand / collapse

Bug Description

There are two issues with the memory/skill nudge trigger logic:

  1. Nudge Counter Reset on Interruption/Failure : When a memory/skill review opportunity is lost due to an empty final_response or an interruption, the memory/skill nudge counters are reset and need to restart accumulation from scratch.
  2. Duplicate Memory Reviews : Duplicate memory reviews occur when _should_review_memory is true while the agent is calling a memory tool within the tool execution loop.

Steps to Reproduce

Issue 1: Counter Reset on Interruption

  1. Set _memory_nudge_interval = 2
  2. Have 1 conversation turn (counter becomes 1)
  3. Start a second conversation but interrupt or fail it
  4. Counter is reset to 0 instead of preserving the state
  5. Need to have 2 more conversation turns to trigger the nudge again

Issue 2: Duplicate Memory Reviews

  1. Set _memory_nudge_interval = 2
  2. Have 1 conversation turn (counter becomes 1)
  3. In the second turn, manually call the memory tool
  4. Duplicate memory review can be triggered

Expected Behavior

  1. Nudge counters should only be reset when we are actually going to spawn a background review process, not just at the start of a conversation. This way, if a conversation is interrupted or fails, the counter state is preserved and the nudge will trigger on the next successful conversation.
  2. Memory nudge checks should happen after tool calls to avoid duplicate reviews when the agent calls memory tools manually.

Actual Behavior

  1. Memory nudge check happens at the start of the conversation, and counters are reset unconditionally.
  2. When _should_review_memory is true and the agent calls a memory tool within the execution loop, duplicate memory reviews occur.

Affected Component

Agent Core (conversation loop, context compression, memory)

Messaging Platform (if gateway-related)

No response

Debug Report

N/A

Operating System

macOS 26.3

Python Version

3.11

Hermes Version

0.10.0

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

The memory/skill nudge trigger logic can be fixed by adjusting the counter reset logic and the timing of memory nudge checks to prevent resets on interruptions and duplicate reviews.

Guidance

  • Review the conversation loop logic to ensure that nudge counters are only reset when a background review process is spawned, not at the start of every conversation.
  • Consider moving the memory nudge check to after tool calls to prevent duplicate reviews when the agent manually calls memory tools.
  • Verify the fix by testing the conversation flow with interruptions and manual tool calls to ensure the nudge counters are preserved and duplicate reviews are avoided.
  • Check the memory_nudge_interval setting to ensure it's correctly implemented and not causing unintended resets or triggers.

Example

No code snippet is provided as the issue description does not include specific code references.

Notes

The fix may require adjustments to the Agent Core component, specifically the conversation loop and context compression logic. The provided Python version and Hermes version may be relevant to the implementation details.

Recommendation

Apply a workaround by adjusting the conversation loop logic to preserve nudge counter state on interruptions and move memory nudge checks to after tool calls, as this approach directly addresses the identified issues.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: Memory/Skill Review Issues in run_agent [1 pull requests]