Repository navigation
Fix #2327: memmy-agent 第二条消息固定报错 session not found - #2572
Open
syzsunshine219 wants to merge 1 commit into
Open
syzsunshine219 wants to merge 1 commit into
syzsunshine219 wants to merge 1 commit into
Conversation
…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
syzsunshine219
marked this pull request as ready for review
November 9, 2026 15:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restores the change proposed in #2328 for review against
mainafter its former base branch,dev-v2.0.33, was deleted. The source commits and authors are preserved.Source head:
3cb77e5ccb12af9c3d0ccb5c2d0d21ae9a10f011This PR is open for review. Review and CI against the current base are pending; validation claims in the original description below refer to the earlier snapshot. The original discussion and evidence remain in #2328.
Original change description
Description
Fixed #2327: memmy-agent second-message "session not found" error.
Root cause:
apps/memos-local-plugin/core/pipeline/memory-core.ts::closeSessionthrewMemosError("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.
How Has This Been Tested?
Automated tests are pending.
Checklist
@whipser030,@hijzyplease review this PR.Reviewer Checklist