Skip to content

fix(server): wait for Codex MCP startup before the turn snapshot - #86

Closed
macodev00 wants to merge 1 commit into
mainfrom
cursor/codex-mcp-catalog-startup-4d6e
Closed

macodev00 wants to merge 1 commit into
mainfrom
cursor/codex-mcp-catalog-startup-4d6e

Conversation

@macodev00

Copy link
Copy Markdown
Owner

Fixes pingdotgg#13437

Problem

Codex snapshots the model-facing tool catalog at turn/start. Optional stdio MCP servers that are still starting are omitted after a short grace, so the first turn only binds the servers that finished first. Later servers can be ready before the model answers and still be missing from that snapshot.

What Changed

CodexAdapterV2 records mcpServer/startupStatus/updated and holds turn/start until every server that has reported in for the thread leaves starting.

This does not call config/mcpServer/reload. That RPC only queues a refresh and an explicit refresh reconnects every configured server.

Scope and approval

Accepted bug, triaged in pingdotgg#13437. Julius confirmed the race on main and prescribed a bounded wait before turn/start until each expected server leaves starting, keyed by server name, with a later ready winning over a spurious cancelled.

Verification

./node_modules/.bin/vp test run apps/server/src/provider/CodexMcpCatalog.test.ts

Test Files 1 passed (1). Tests 8 passed (8). Duration 242ms. Started 2026-10-04 06:43:16 UTC.

The tests cover a partial catalog (one server ready, one still starting), a spurious cancelled that later becomes ready, the idle fast path, a timeout that does not block the next turn, threadless notifications, thread isolation, and failed not blocking.

./node_modules/.bin/vp test run apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts -t "waits for native start before interrupting an acknowledged queued turn"

Tests 1 passed, 132 skipped (133). Duration 4.98s. Started 2026-10-04 06:43:35 UTC. startTurn still completes when no MCP startup status has been reported.

./node_modules/.bin/vp run --filter t3 typecheck

Exit 0. Pre-existing Effect language-service suggestions only.

Limitations

The wait only includes servers that have already emitted mcpServer/startupStatus/updated when the turn samples the catalog. A first starting event that arrives after that sample can still miss that turn.

A server that is still starting, or stuck on cancelled without a later ready, is omitted after 30 seconds. Later turns do not wait for it again unless it reports starting again.

Not run against a live Codex app-server or the 10–20s stdio servers from the report.

Open in Web Open in Cursor 

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Oct 4, 2026
Codex snapshots the model-facing tool catalog at turn/start. A stdio
server still in starting is left out, so the first turn only sees the
servers that finished first. Hold the turn until each reported server
leaves starting, and let a later ready replace a spurious cancelled.
A 30s bound still starts the turn when a server never finishes.
@macodev00
macodev00 force-pushed the cursor/codex-mcp-catalog-startup-4d6e branch from e593008 to a765f36 Compare October 4, 2026 06:46
@macodev00

Copy link
Copy Markdown
Owner Author

Opened upstream.

@macodev00 macodev00 closed this Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Codex turn sees partial MCP tool catalog during server startup

1 participant