Bug Description
In gateway/messaging-platform usage (observed on Telegram), Hermes appears to create a fresh AIAgent per inbound message while continuing the persisted session history. The periodic self-improvement memory review is gated by the instance variable _turns_since_memory, which is initialized to 0 in AIAgent.__init__.
Because the gateway creates a new agent object per message, _turns_since_memory starts at 0 every turn and memory.nudge_interval may never be reached. In practice this means the background Self-improvement review stops appearing and durable user corrections/workflow lessons are not proactively saved.
This is related to #18369, but the scenario is not only users manually starting /new; it can happen in normal long-running gateway conversations where the conversation history persists but the agent instance does not.
Steps to Reproduce
- Configure memory review with the default-ish settings:
memory:
memory_enabled: true
user_profile_enabled: true
nudge_interval: 10
- Run Hermes through the gateway (Telegram observed).
- Continue a normal conversation for many turns without
/new.
- Watch for
💾 Self-improvement review: messages or memory/skill background review tool actions.
Expected Behavior
The memory review counter should survive gateway turn boundaries, or be reconstructed from persisted session history, so that memory.nudge_interval still triggers in messaging-platform sessions.
Actual Behavior
The fresh per-message AIAgent resets _turns_since_memory to 0, so the turn-based trigger can be starved indefinitely in gateway mode.
Observed user-facing result:
- no
Self-improvement review messages for a long time despite many turns and obvious durable lessons,
- important workflow correction was not saved until manually investigated,
- compact user memory became nearly full, and no automatic memory compaction/Obsidian-style detail fallback occurred.
Environment
- Hermes Agent:
v0.13.0 (2026.5.7)
- Source checkout:
NousResearch/hermes-agent, branch main
- Platform: Telegram gateway
- Config snippet:
memory:
memory_enabled: true
user_profile_enabled: true
memory_char_limit: 2200
user_char_limit: 1375
nudge_interval: 10
flush_min_turns: 6
skills:
creation_nudge_interval: 15
Local Patch Tested
A minimal local fix was tested: hydrate _turns_since_memory from persisted conversation_history when a fresh agent starts with counter 0.
Conceptually:
prior_user_turns = sum(1 for msg in conversation_history if msg.get("role") == "user")
self._turns_since_memory = prior_user_turns % self._memory_nudge_interval
Then the normal per-turn increment can trigger the review when the effective turn count reaches the interval.
Regression test added locally:
tests/run_agent/test_memory_review_counter.py
Result:
3 passed
python -m py_compile run_agent.py # ok
Notes / Questions
- This same lifecycle issue may also affect
_iters_since_skill and skills.creation_nudge_interval in gateway mode.
- A more robust upstream solution might persist nudge state in the session DB, derive it from history, or trigger background review on session split/reset.
- The user expectation is that self-improvement works automatically in messenger mode; users should not have to manually notice that memory is full or that reviews stopped triggering.
Bug Description
In gateway/messaging-platform usage (observed on Telegram), Hermes appears to create a fresh
AIAgentper inbound message while continuing the persisted session history. The periodic self-improvement memory review is gated by the instance variable_turns_since_memory, which is initialized to0inAIAgent.__init__.Because the gateway creates a new agent object per message,
_turns_since_memorystarts at0every turn andmemory.nudge_intervalmay never be reached. In practice this means the backgroundSelf-improvement reviewstops appearing and durable user corrections/workflow lessons are not proactively saved.This is related to #18369, but the scenario is not only users manually starting
/new; it can happen in normal long-running gateway conversations where the conversation history persists but the agent instance does not.Steps to Reproduce
/new.💾 Self-improvement review:messages or memory/skill background review tool actions.Expected Behavior
The memory review counter should survive gateway turn boundaries, or be reconstructed from persisted session history, so that
memory.nudge_intervalstill triggers in messaging-platform sessions.Actual Behavior
The fresh per-message
AIAgentresets_turns_since_memoryto0, so the turn-based trigger can be starved indefinitely in gateway mode.Observed user-facing result:
Self-improvement reviewmessages for a long time despite many turns and obvious durable lessons,Environment
v0.13.0 (2026.5.7)NousResearch/hermes-agent, branchmainLocal Patch Tested
A minimal local fix was tested: hydrate
_turns_since_memoryfrom persistedconversation_historywhen a fresh agent starts with counter0.Conceptually:
Then the normal per-turn increment can trigger the review when the effective turn count reaches the interval.
Regression test added locally:
Result:
Notes / Questions
_iters_since_skillandskills.creation_nudge_intervalin gateway mode.