fix(mcp): reinitialize expired HTTP sessions - #2387
Open
lurenjia534 wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: e03fd73 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
lurenjia534
marked this pull request as ready for review
July 29, 2026 21:52
commit: |
Contributor
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Related Issue
Resolve #2380
Problem
After a Streamable HTTP MCP server restarted, its old session id could remain attached to the client transport. A tool retry then sent the same expired id again instead of establishing a new session, so the server repeatedly returned
Unknown session id.What changed
-32600response with an explicit invalid-session and reinitialize message.ConnectionClosed, because its server-side outcome is unknown and replaying could duplicate side effects.Validation
691ec4679ea19d6be8ac18f359088384ed3e446dand fixede03fd73a947bf34668059ff694ece2566e539f8c: the added invalid-sessionscenario failed on upstream with the server's
Unknown session idresponse, then passed unchanged after the fix by establishing a replacement
session and retrying the interrupted call once.
pnpm --filter @moonshot-ai/agent-core exec vitest run test/mcp/client-http.test.ts test/mcp/connection-manager.test.ts test/mcp/tool-manager-mcp.test.ts— 93 passedpnpm --filter @moonshot-ai/agent-core exec vitest run— 4,133 passed, 30 skipped, 3 expected failures, 1 todopnpm --filter @moonshot-ai/agent-core typecheckpnpm --filter @moonshot-ai/agent-core buildpnpm --filter @moonshot-ai/kimi-code typecheckpnpm --filter @moonshot-ai/kimi-code buildnode apps/kimi-code/dist/main.mjs --versionpnpm exec oxlint --type-aware --quietgit diff --checkChecklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.