Repository navigation
fix(anthropic): stop reporting success after OpenClaw MCP startup fails - #176154
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesReject Claude CLI turns when startup explicitly reports a disconnected OpenClaw MCP server, retire the process, and explain how to retry. Example: Claude Code 2.1.309 reports openclaw status failed after delayed Gateway MCP startup.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a confirmed current-main failure without introducing an actionable defect; exact-head CI remains pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Anthropic plugin consumes Claude Code stream-json records, delivers turn output to the shared CLI runner, and owns subprocess reuse and retirement. flowchart TD
A[Gateway agent request] --> B[Shared CLI runner]
B --> C[Anthropic CLI runtime]
C --> D[Claude Code process]
D --> E[Startup MCP status]
E --> C
C --> F[Turn output or startup error]
C --> G[Existing session cleanup]
Technical reviewBest possible solution: Use the existing init and session-cleanup owners to reject explicitly disconnected OpenClaw startup while preserving healthy and absent-entry behavior. Do we have a high-confidence way to reproduce the issue? Current-main source still accepts failed init followed by success, and the supplied built-Gateway reproduction demonstrates that failure on pinned main; this read-only review ran no target code. Is this the best way to solve the issue? The patch restores the configured tool-surface contract at its existing protocol owner, preserves cleanup ordering, and avoids timeout changes, automatic replay, or a second lifecycle path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 176c9c7496fd. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +15, Tests 0, Docs +5. Total +20 across 4 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 30, 2026, 8:00 AM ET / 12:00 UTC (Revision 5). |
|
@clawsweeper re-review Recovery guidance is fixed in 26931797. The updated PR body includes real Claude Code 2.1.278 evidence through the production executor: failed MCP startup rejects the turn, retires the original process, and the next request succeeds on a fresh process. Official npm 2026.10.4 configuration is accepted unchanged at this head. This is configuration compatibility, not a running Gateway or state-database upgrade. The CI gate has passed for 26931797. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Added captured test output and the recorded runtime JSON to the PR body for 26931797, including the failed-process exit and successful retry on a different PID. The real Claude Code executable used isolated state and local MCP/API responses; no live Gateway upgrade or external model request is claimed. No code changes since the previous review. |
|
🦞👀 Re-review progress:
|
2693179 to
0724208
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Built Gateway / genuine Claude Code startup proofIndependently installed and built pinned main Used official Claude Code 2.1.309, normal No account, login, paid key or external model request: a synthetic API-key profile feeds the normal credential path. Genuine Claude traffic to Stall and observed outcomesA process-local preload delays only the built Gateway's Native stdout is observed passively at the real child-process pipe. The following {"type":"system","subtype":"init","mcp_servers":[{"name":"openclaw","status":"failed","source":"dynamic"}]}
Main delayed elapsed: 32,256 ms and 31,775 ms. Candidate delayed elapsed: 32,608 ms and 31,802 ms. Healthy controls: 1,853 ms main / 1,957 ms candidate. Both candidate failures surface this exact operator-facing JSON: {
"ok": false,
"origin": "gateway",
"error": {
"type": "cli_error",
"message": "Claude Code started without the OpenClaw MCP server (status failed). The CLI process was retired; retry the request to start a fresh process."
}
}Both main runs instead return: {
"status": "ok",
"summary": "completed",
"toolSummary": {"calls": 0, "tools": [], "failures": 0}
}The matrix above uses the retained main run and the completed candidate run. An additional candidate observation emitted Regression consolidationRemoved the separate startup-test file and folded failed/pending rejection, exited-process retirement, fresh-process recovery and subsequent warm reuse into the existing native-stdio suite. Existing argument/private-context warm-turn coverage now also covers a connected OpenClaw server despite an optional failed server, and an absent OpenClaw entry. Shared warm-turn assertions preserve the original independent contracts while removing duplicated setup/assertions. Whole-PR test-line delta is 0, with no allocation or new test file. Focused validation
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in f964859. Thanks @xyi74976-del. Claude CLI turns now report it when the openclaw MCP server fails to start, instead of running without tools. |
…ls (openclaw#176154) fix(anthropic): fail the Claude CLI turn when the openclaw MCP server fails to start Fixes openclaw#176138. When the Gateway was slow to answer and Claude Code's own 5-second MCP connect timeout expired, Claude reported the openclaw MCP server as `failed` in its `system/init` message. OpenClaw ignored that, so the turn ran without any OpenClaw tools and still reported success. OpenClaw now checks the init message, ends the session through the existing closeSession path and reports a startup failure with retry guidance. Evidence: real Claude Code 2.1.309 routed through a trusted-CA HTTPS CONNECT fixture (no login, no paid key) with built Gateways. A delayed Gateway MCP dispatch produced `system/init.mcp_servers: [{name:"openclaw",status:"failed"}]`. Main reported success with 0 tool calls (twice); with this change the turn exited with the startup failure and retry guidance (twice). With a normal connect, both refs ran ToolSearch and a Gateway-backed Read with the file contents. Details: openclaw#176154 (comment). Thanks @xyi74976-del. Co-authored-by: Ayaan Zaidi <[email protected]>
Retire the existing CLI process when its init message reports disconnected OpenClaw MCP, and give actionable retry guidance rather than reporting a tool-less success. Preserve optional-server and absent-status behavior. (cherry picked from commit f964859) Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Closes #176138
What Problem This Solves
Claude Code can explicitly report that its required
openclawMCP server failed to connect, then complete a turn successfully without Gateway tools. OpenClaw previously ignored that startup status and could retain the affected process for later turns.Reported by @Oldrich333; original fix and commits by @xyi74976-del are retained.
User Impact
A Claude CLI turn whose init explicitly reports a non-connected OpenClaw MCP server now fails visibly with a concrete retry instruction. The process is retired and joined so the next request starts fresh. A connected OpenClaw server remains reusable even when an unrelated optional server failed; an init without an OpenClaw entry keeps its existing behavior.
Why This Change Was Made
The Anthropic plugin's existing init owner now checks the reported OpenClaw server and routes startup failure through the existing session-close owner before accepting more output. No timeout override, automatic replay, dependency, permission, authentication or SDK change is introduced.
Evidence
Captured built-Gateway / genuine Claude Code proof and focused checks.
Independently built pinned main
5eda466704861324a87e05a488cb10888e66b8a7and contributor candidate55e9b8579bb58d5916d069d78b53d6a91e60d84f. The current revision changes tests only; the production guard is unchanged from the proven candidate.Used real official Claude Code 2.1.309, the built Gateway, normal
claude-clibackend and shippedagentcommand. A trusted-CA HTTPS CONNECT Messages fixture supplies local responses without a login or paid key; the container had no external network during proof. An in-process latency preload holds the actual Gateway MCP request dispatch beyond native startup/fallback timeouts; it does not manufacture native init or tool-result records.system/init.mcp_serversreportsopenclaw: failed, but the Gateway returns completed success with 0 tool calls.The separate added test file is removed. The existing native-stdio suite retains startup rejection, exited-process retirement, fresh-process recovery, warm reuse, optional-server failure and absent-entry contracts. Shared warm assertions replace duplicate assertions/setup without removing their independent checks.
Whole-PR surface: production +15/-0, tests/support +31/-31 (net 0), docs +5/-0. No new test file or allocation.
Merge Risk
Two-way door: reverting restores the previous startup acceptance behavior; this changes no persisted schema or configuration. Blast radius is Claude CLI turns whose init explicitly names a non-connected
openclawMCP server. Healthy and absent-entry startup behavior remains covered. Genuine CLI failures retain the existing fallback behavior.