Skip to content

Codex App: spurious Removed/Added deferred tool namespaces during MCP startup #64529

Backlog

Description

@CHZarles

What version of the Codex App are you using (From “About Codex” dialog)?

26.1120.50957 (bundled app-server/codex-cli 0.171.0-alpha.13.2)

What subscription do you have?

ChatGPT (plan detail omitted; not relevant to this issue)

What platform is your computer?

Darwin 25.5.0 arm64 arm (macOS 26.5.2, build 25F84)

What issue are you seeing?

After an app-server restart, the first sampling step after turn/start can emit a spurious Removed deferred tool namespaces for an MCP namespace that is still starting. When the MCP server becomes ready, a later step emits Added deferred tool namespaces for the same namespace. Net change is zero, but the model receives contradictory context and the transcript/Context Inspector shows a tool update that never happened.

Reproduced twice on the same machine:

Session 1 — thread 01a21cfd-7e7b-7041-8e5e-d8a309cf9a55, turn 01a222ce-cb3f-7cf1-965d-c21261bfcb2e (2026-11-28, UTC)

  • 15:37:48.403 app-server connection: cause=stop_process, disconnected
  • 15:38:27.538 turn/start
  • 15:38:27.546 mcp_server_startup_status_updated server=drawio status=starting
  • 15:38:28.550 developer message: Removed deferred tool namespaces: mcp__drawio
  • 15:38:28.550 world_state: tools.mcp__drawio = null
  • 15:38:28.907 mcp_server_startup_status_updated server=drawio status=ready
  • 15:38:42.317 model calls exec_command
  • 15:38:42.487 developer message: Added deferred tool namespaces: mcp__drawio
  • 15:38:42.487 world_state: tools.mcp__drawio = "<description>"

Session 2 — thread 01a224eb-9766-72e3-9fac-1bc152ee5149 (2026-11-29, UTC)

  • 02:02:38.839 turn/start
  • 02:02:38.847 drawio status=starting
  • 02:02:39.857 developer message: Removed deferred tool namespaces: mcp__drawio
  • 02:02:39.858 world_state: tools.mcp__drawio = null
  • 02:02:40.328 drawio status=ready
  • 02:02:50.982 developer message: Added deferred tool namespaces: mcp__drawio
  • 02:02:50.982 world_state: tools.mcp__drawio = "<description>"

The drawio server was ready 1.36s (session 1) / 0.47s (session 2) after starting. The gap before Added is just the next sampling step after the model's tool call, not a timeout.

The removed/added text is the deferred namespace summary, not the full tool schema. It is truncated by Codex at roughly 240 characters and ends with a literal ...; Context Inspector records it verbatim.

What steps can reproduce the bug?

  1. Restart the Codex app (or let the app-server restart).
  2. Open/continue a thread that previously had mcp__drawio in its world state.
  3. Send the first message; the first sampling step runs while the drawio MCP server is still starting.
  4. Observe Removed deferred tool namespaces: mcp__drawio in the rollout, then Added ... after the MCP server is ready and the next step is assembled.

What is the expected behavior?

A namespace whose MCP server is still starting should not be reported as removed. Either wait for pending MCP startup before the first world-state build, or carry forward the previous entry until the server is ready or terminally failed. The model should not receive Removed for a server that is about to become ready.

Additional information

Root cause: ToolsState::render_diff in codex-rs/core/src/context/world_state/tools.rs compares the current step_context.tool_router.deferred_tool_namespaces() (in-memory registry) with the persisted previous world_state checkpoint (codex-rs/core/src/session/world_state.rs). After an app-server restart, the checkpoint still contains the namespace, but the new process's registry is empty while the MCP server is starting; the diff renders Removed. When the server is ready, the next step renders Added.

Suggested fix:

  • Pass MCP startup status into the world-state diff and exclude namespaces whose server is starting from the removed set; carry them forward.
  • Or delay the first world-state build / first sampling step until pending MCP startup settles.
  • Add a regression test in codex-rs/core/src/context/world_state/tools_tests.rs: previous={drawio}, current={}, starting={drawio} -> no Removed; after ready current={drawio}, previous={} -> Added.

Related: #59191 (permanent loss of cua_repl after app update/resume; same startup-race family), #56964 (Figma tools vanish after app-server reconnect). This report is the transient/self-healing variant and may be a useful minimal repro.

No conversation content or credentials are included. Log excerpts available on request.

Activity

  1. added
    bug
    app
    mcp
    app-server
    on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appapp-serverbugmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions