Skip to content

Fix #2327: memmy-agent 第二条消息固定报错 session not found - #2328

Closed
Memtensor-AI wants to merge 1 commit into
MemTensor:dev-v2.0.33from
Memtensor-AI:bugfix/autodev-2327-20260902070028337
Closed

Fix #2327: memmy-agent 第二条消息固定报错 session not found#2328
Memtensor-AI wants to merge 1 commit into
MemTensor:dev-v2.0.33from
Memtensor-AI:bugfix/autodev-2327-20260902070028337

Conversation

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

Description

Fixed #2327: memmy-agent second-message "session not found" error.

Root cause: apps/memos-local-plugin/core/pipeline/memory-core.ts::closeSession threw MemosError("session_not_found") when the session was no longer in the orchestrator's in-memory live map. After the first message, the adapter's on_session_end hook calls session.close which evicts the session from the live map. Any subsequent duplicate close (lifecycle race, adapter retry, memmy-agent bridge re-firing) hit the null branch and threw, surfacing to the user on the second message.

Fix: Made closeSession idempotent — unknown session ids are a silent no-op with a debug log, matching the existing semantics of closeEpisode/discardEmptyEpisode. Added 4 regression tests in tests/unit/pipeline/regression-2327-second-message.test.ts. All 176 session + pipeline unit tests pass.

Changed files: core/pipeline/memory-core.ts (fix), core/pipeline/README.md + ALGORITHMS.md (doc update), tests/unit/pipeline/regression-2327-second-message.test.ts (new regression tests).

Related Issue (Required): Fixes #2327

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Automated tests are pending.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have created related documentation issue/PR in MemOS-Docs (if applicable)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

@whipser030, @hijzy please review this PR.

Reviewer Checklist

…on_not_found (MemTensor#2327)

When the host fires session.close (e.g. /new, adapter lifecycle end) and
then immediately starts a new turn, closeSession could be called on a session
id that is no longer in the orchestrator's live Map. Previously this threw a
hard MemosError('session_not_found') that surfaced to the user as an error
on the second message.

Make closeSession idempotent: if the session is not found, log a debug
message and return without error. The turnStartApiLogBySession entry is
still cleaned up. This mirrors the existing behaviour of closeEpisode and
discardEmptyEpisode, which already handle the not-found case as a no-op.

Update README.md and ALGORITHMS.md to document the new semantics.

Add regression test (tests/unit/pipeline/regression-2327-second-message.test.ts):
- closeSession on already-closed session does not throw
- openEpisode succeeds on second message after closeSession
- openEpisode succeeds when adapter skips re-openSession (defensive path)
- onTurnStart succeeds on second message after closeSession (ensureSession reopens)

Fixes MemTensor#2327
@Memtensor-AI Memtensor-AI added ai:generated Generated or modified by AI | 由 AI 生成或修改 area:plugin OpenClaw & Hermes status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Sep 2, 2026
@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

🤖 Open Code Review

Target: PR #2328
Task: 1d452ba963e2f9cb
Base: dev-v2.0.33
Head: bugfix/autodev-2327-20260902070028337
Head SHA: 3cb77e5ccb12af9c3d0ccb5c2d0d21ae9a10f011

OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

✅ Automated Test Results: PASSED

All tests passed (52/52 executed). memos_local_plugin/unit: 52/52. Duration: 12s [advisory, non-gating] AI-generated tests on branch test/auto-gen-1d452ba963e2f9cb-20260902164416: 20/21 passed — these do NOT affect the PR verdict; review the branch manually.

Branch: bugfix/autodev-2327-20260902070028337

@Memtensor-AI Memtensor-AI added status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 and removed status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Sep 2, 2026
@CarltonXiang
CarltonXiang deleted the branch MemTensor:dev-v2.0.33 September 3, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:generated Generated or modified by AI | 由 AI 生成或修改 area:plugin OpenClaw & Hermes status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants