Skip to content

fix(grok): await server_status ready for every serveMcpTools server - #1128

Merged
stamp-build[bot] merged 1 commit into
mainfrom
agent/lookout/fix-grok-mcp-startup
Nov 22, 2026
Merged

stamp-build[bot] merged 1 commit into
mainfrom
agent/lookout/fix-grok-mcp-startup

Conversation

@stamp-build

@stamp-build stamp-build Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Lookout (open-agent-runtime) opened via Stamp · View →


Fixes #1125.

Cause

On both Grok 1.0.70 (CI pin) and 1.0.92 (latest), _x.ai/mcp/server_status is emitted asynchronously and can arrive after _x.ai/mcp_initialized (~50-100 ms later for fast-settling loopback servers). Previously grokMcpStartup (packages/oar/src/runtimes/grok/mcp-startup.ts) resolved wait() as soon as _x.ai/mcp_initialized arrived, setting finished = true and ignoring the subsequent unavailable status report. As a result, opens with a closed port, HTTP 401, HTTP 500, resumed closed port, or healthy + closed served servers silently succeeded instead of rejecting.

Change

  • packages/oar/src/runtimes/grok/mcp-startup.ts: require BOTH _x.ai/mcp_initialized AND _x.ai/mcp/server_status with status === "ready" for every server in served before resolving wait(). Ignore non-terminal status === "initializing" (confirmed in Grok 1.0.92 McpServerStatusPayload [sym]: ready, initializing, unavailable, needsauth/needs_auth), and reject immediately on any other non-ready terminal status using params.reason ?? status.
  • tests/grok/grok-mcp-startup.test.ts: added unit tests covering _x.ai/mcp_initialized arriving before _x.ai/mcp/server_status (both ready across multiple served servers with initializing ignored, and unavailable / needsauth rejections), plus unavailable before mcp_initialized and pre-reply buffering.
  • sea-trial/vendor/serve-mcp-tools.vendor.test.ts: added two real grok-aimock vendor tests covering (1) rejection with Grok served MCP server "deadhost": handshake_failed (and no bearer token leak) on a closed serveMcpTools server, and (2) session/new + session/resume with an empty-tool (tools: []) serveMcpTools server.
  • docs/runtimes/grok.md: updated the Session MCP servers barrier description to state that OAR waits for both _x.ai/mcp_initialized and per-server status: "ready", handles both wire orderings across 1.0.70 and 1.0.92 (new and resume, including empty-tool servers), treats initializing as non-terminal, and rejects on non-ready terminal statuses (unavailable, needsauth/needs_auth).

Call-Site Audit

Grepped all openReadiness, waitForOpenReadiness, and grokMcpStartup call sites across packages/oar/src/:

  • packages/oar/src/runtimes/grok/mcp-startup.ts (changed): sole AcpOpenReadiness implementation.
  • packages/oar/src/runtimes/grok/session.ts:166 (unchanged): wires openReadiness: grokMcpStartup on grokAcpProfile.
  • packages/oar/src/shared/acp/session-state.ts:36, open-readiness.ts:17, profile.ts:281 (unchanged): generic ACP readiness plumbing already passes all _x.ai/* extension notifications to readiness.observe on both new and resume and bounds readiness.wait with the session-open deadline.

Verification

  • Real Grok 1.0.92 (grok 1.0.92 (b06756fd6256) [stable]) + aimock: OAR_TEST=grok-aimock pnpm vitest run sea-trial/vendor/serve-mcp-tools.vendor.test.ts (3/3 passed: host tool call + no token leak, dead served server rejects handshake_failed + no token leak, empty-tool new + resume pass).
  • Real Grok 1.0.70 (grok 1.0.70 (f50904eaee6c) [stable], CI pin) + aimock: OAR_TEST=grok-aimock pnpm vitest run sea-trial/vendor/serve-mcp-tools.vendor.test.ts (3/3 passed).
  • pnpm run build && pnpm run typecheck && pnpm run lint (0 warnings, 0 errors).
  • pnpm vitest run tests/grok/grok-mcp-startup.test.ts (6/6 passed).
  • Full CI=1 pnpm run check (5,524/5,525 passed in parallel run; the 1 unrelated tests/antigravity/antigravity-account-usage-boundaries.test.ts load flake passed 13/13 on re-run) + pnpm run sea-trial (19/19 mock passed).

Merge is held pending lift of the v0.129.1 release hold.

@stamp-build
stamp-build Bot force-pushed the agent/lookout/fix-grok-mcp-startup branch from 7e47512 to 0c07991 Compare November 22, 2026 12:27
@stamp-build
stamp-build Bot merged commit 8674be0 into main Nov 22, 2026
25 checks passed
@stamp-build
stamp-build Bot deleted the agent/lookout/fix-grok-mcp-startup branch November 22, 2026 12:33
@stamp-build stamp-build Bot mentioned this pull request Nov 23, 2026
stamp-build Bot added a commit that referenced this pull request Nov 23, 2026
<!-- stamp:review:v1 -->
<sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg"
width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b>
(open-agent-runtime) opened via Stamp · <a
href="https://stamp.build/review?receipt=prc_5d3a397b07e608c8e27fe089d5ec351b"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img
src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg"
width="13" height="12" align="absmiddle" alt=""></picture> View
→</a></sup>

---
<!-- /stamp:review:v1 -->

## OAR 0.130.0

### Features

- **Kimi capability-gated KAP session adapter with ACP fallback**
(#1137, #1156, #1157). Adds the Kimi Agent Protocol (KAP) session
adapter gated on server capabilities with automatic fallback to ACP on
unpatched installations, clears pending steers on aborted turns with
steer-gap abort support, and projects partial tool input text as deltas
with complete input on item end.
- **Subagent selected-model reporting** (#1148). Reports the model
selected for subagent sessions.
- **Antigravity local file skill discovery** (#1144, #1145). Reads skill
files locally on Antigravity 1.5.14 and enables file skill discovery on
1.5.15.

### Fixes

- **Pi RPC private-pipe startup config and MCP credential admission**
(#1161). Delivers Pi RPC startup configuration once over the
cross-platform private fd 3 pipe with no config file written to disk,
and admits `mcpServerCredentials` on Pi RPC across all platforms.
- **Claude Code private-file MCP credential handoff on non-FIFO
platforms** (#1160). Delivers credentialed MCP config through an
owner-only temporary file on platforms without FIFOs (including
Windows), waits for Claude `initialize`, and unlinks the file before
session open returns.
- **ACP `session/load` 60-second default deadline and Grok open bounds**
(#1159). Gives ACP `session/load` a 60-second default deadline, shares a
single deadline across open and readiness checks, and sets Grok's
default request timeout to 30 seconds.
- **Grok `serveMcpTools` readiness wait** (#1128). Awaits
`server_status` ready for every `serveMcpTools` server before completing
startup.
- **DSH cross-process startup serialization** (#1119). Serializes
same-profile startup across processes.
- **Factory tool projection, compaction context, and OAuth email**
(#1133). Projects `script_only` tools, refreshes post-compact context,
and surfaces OAuth email.
- **Pi Durable tool input and CLI runtime dispatch alignment** (#1143).
Aligns Pi Durable tool input handling and CLI runtime dispatch with
contracts.

### Documentation, CI, and Tests

- **Documentation alignment** (#1124, #1132, #1135, #1136, #1138, #1139,
#1140, #1141, #1142). Aligns design docs, specs, runtime guides, package
READMEs, and Kimi KAP wire and verification records with shipped
contracts, and links `awesome-oar` in README.
- **CI and test reliability** (#1122, #1127, #1129, #1131, #1146, #1147,
#1149, #1150, #1152, #1158). Tightens native fixture cleanup, Windows
case-insensitive `Path` handling in CI sharding, the Antigravity 1.5.14
ACP baseline, bounded fetch retries, and test timing stability.

Full diff: v0.129.1...v0.130.0

Co-authored-by: Cindy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

grok: serveMcpTools open resolves before _x.ai/mcp/server_status, silently opening on failed served servers

0 participants