Skip to content

fix(gateway): init memory store for flush agent - #6179

Closed
r266-tech wants to merge 1 commit into
NousResearch:mainfrom
r266-tech:fix/gateway-flush-memory-6157
Closed

fix(gateway): init memory store for flush agent#6179
r266-tech wants to merge 1 commit into
NousResearch:mainfrom
r266-tech:fix/gateway-flush-memory-6157

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Summary

Fixes #6157 — the gateway pre-reset memory flush created a temporary AIAgent with skip_memory=True, which prevented _memory_store from being initialised. Since the memory tool was still in enabled_toolsets, the model could call it but every call returned "Memory is not available." — making the flush path completely non-functional for all messaging platform sessions (Telegram, Discord, Matrix, etc.).

Changes

  • gateway/run.py: skip_memory=Trueskip_memory=False (1 line)
  • tests/gateway/test_flush_memory_store.py: AST-based regression test that verifies skip_memory=False in the flush agent constructor

Root cause

tmp_agent = AIAgent(
    ...
    skip_memory=True,   # ← prevents _memory_store initialization
    enabled_toolsets=["memory", "skills"],  # ← memory tool IS available
)

When skip_memory=True, run_agent.py:977-992 skips MemoryStore(...) creation, leaving _memory_store = None. The memory tool at memory_tool.py:452 then returns an error on every call.

Test plan

  • Regression test passes (pytest tests/gateway/test_flush_memory_store.py)
  • Manual: trigger a session reset on a messaging platform, verify memory flush produces writes

The pre-reset memory flush created a temporary AIAgent with
skip_memory=True, preventing _memory_store initialization. The memory
tool was in enabled_toolsets so the model could call it, but every call
returned "Memory is not available." — making the flush completely
non-functional for all messaging platform sessions.

Change skip_memory to False so the MemoryStore is properly initialised.
The flush prompt already includes memory state read from disk, so any
system-prompt injection from the memory provider is redundant but
harmless.

Closes NousResearch#6157
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the careful investigation and fix, @r266-tech! The root cause you identified was real at the time.

This is an automated hermes-sweeper review.

Unfortunately this PR is now obsolete:

  • Commit ea01bdceb (merged Apr 25 2026, refactor(memory): remove flush_memories entirely #15696) removed the entire flush_memories subsystem from main — GatewayRunner._flush_memories_for_session, _async_flush_memories, AIAgent.flush_memories(), and all call sites in gateway/run.py, run_agent.py, and cli.py were deleted.
  • The bug this PR fixes (skip_memory=True on the flush agent) can no longer occur because the flush code path no longer exists.
  • grep -rn '_flush_memories\|flush_memories' gateway/ returns no results on current main.
  • The test file this PR adds (tests/gateway/test_flush_memory_store.py) does not exist on main and would be testing a removed feature.

The underlying concern (memory extraction on session reset) is now handled by the background memory review loop, which runs every 10 turns on both CLI and gateway without the blocking/cache-invalidating flush approach. Closing as superseded.

@teknium1 teknium1 closed this Apr 27, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery tool/memory Memory tool and memory providers labels Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gateway memory flush creates agent with skip_memory=True, making memory tool non-functional

3 participants