-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
MCP runtimes duplicate stdio sessions for identical workspace/config #95506
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.maintainerMaintainer-authored PRMaintainer-authored PR
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.maintainerMaintainer-authored PRMaintainer-authored PR
Type
Fields
Priority
None yet
Problem
Current MCP runtime ownership appears to be per session, even when many sessions use the same workspace and identical MCP config. That means multi-session workloads can duplicate MCP runtime state, catalog work, and stdio server processes/transports.
This is related to existing MCP performance/process-pressure reports, but it is a narrower source-level cardinality issue:
bundle-toolsprep regression with stdio MCP servers.bundle-toolslatency on every request.This issue is specifically about identical
(workspaceDir, MCP config fingerprint)sessions fanning out into duplicate session-scoped MCP runtimes and duplicate stdio catalog work.Validation Performed
I added a temporary/focused proof test locally against current code.
The test creates 8 sessions with:
workspaceDirtools/listFor each session, the test calls
getOrCreateSessionMcpRuntime(...). It then samples the MCP runtime census before catalog materialization.Observed before catalog materialization:
Then the test calls
runtime.getCatalog()for every runtime, which forces catalog loading and stdio MCP connection. It samples the census again and reads the stdio server log.Observed after catalog materialization:
This shows that identical workspace/config sessions currently fan out into one connected stdio MCP server session and one
tools/listrequest per OpenClaw session.Temporary Test Shape
The local proof test was added to
src/agents/agent-bundle-mcp-runtime.test.tsand uses the existing test helper that writes a lightweight stdio MCP server.Pseudo-shape:
Additional Measurement
I also ran a temporary local measurement through the actual
diagnostics.stabilityhandler using no-server MCP configs. This avoids spawning many child processes while checking runtime cardinality behavior.For identical workspace/config sessions:
After catalog materialization in that no-server case:
Cleanup also behaved as expected:
That measurement proves the runtime/catalog cardinality problem scales linearly with session count even when workspace/config cardinality is 1. The stdio proof test above proves the same pattern extends to actual connected MCP stdio sessions and duplicate
tools/listcalls.Why This Matters
For many concurrent sessions in the same workspace with the same MCP config, OpenClaw can duplicate:
tools/listrequestsThis looks like significant avoidable resource pressure in multi-session workloads.
Proposed Direction
Investigate sharing MCP runtime/catalog/transport ownership by
(workspaceDir, configFingerprint)instead of by session alone, while keeping session-specific lifecycle state separate.The fix needs to preserve:
Acceptance Criteria
tools/listcalls collapse where sharing is valid.