Skip to content

bridge: codex mcp tool approval cards, and no codex prompt left unanswerable - #169

Open
morajabi wants to merge 2 commits into
mainfrom
claude/codex-mcp-approvals-734f0b
Open

morajabi wants to merge 2 commits into
mainfrom
claude/codex-mcp-approvals-734f0b

Conversation

@morajabi

@morajabi morajabi commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

When Codex asks to run an MCP tool, Inline showed only the line Allow the coolify MCP server to run tool "manage_notifications"?, with nothing to press. Codex waited until someone ran /stop.

Codex sends these as a form elicitation with an empty requestedSchema and _meta.codex_approval_kind: "mcp_tool_call". Main mapped that to a question with zero fields: no buttons, no answer path.

This PR also closes the other Codex cases from the stuck-prompt audit that live in the same code.

What changes

Codex MCP tool approvals (crates/agent-driver-codex)

  • A message-only elicitation is now an approval card, using the existing tool card that Claude's MCP approvals use:
    • title "Codex wants to use server · tool"
    • the tool's arguments as JSON, bounded (12 args, 600 chars per string, 8 items, depth 3) with control and bidi-override characters removed
    • Codex's own message, shown only when it says more than the generic question
  • Choices match the Codex TUI (tui/src/bottom_pane/mcp_server_elicitation.rs): Allow, Allow for this session / Always allow only when _meta.persist allows them, and Cancel.
    • The TUI offers no Deny for tool approvals. Cancel skips that one call and the turn goes on.
    • Cancel sends _meta.codex_approval_cancellation_reason: "user", as the TUI does.
    • Other message-only requests get Allow / Deny / Cancel.
  • Responses are the whole elicitation response, e.g. {"action":"accept","content":null,"_meta":{"persist":"session"}}.

Unanswered and stale cards

  • An elicitation's turnId is nullable. A request without one now belongs to its thread's running turn, so its card closes ("No longer needed") when that turn ends or is interrupted.
  • A sub-agent's pending requests now close with the sub-agent's own turn. Before, they later read "Answered outside Inline".
  • A tap on a closed card reaches nothing.

Other stuck-prompt cases from the audit

  • Sub-agent threads are registered from thread/started (parentThreadId), so a request that arrives before the spawn item still shows a card. A request from a thread no session knows is still refused (-32601). The chat now says so with an error-level "Request declined" notice, titled the way Claude's declined requests are in bridge: stop prompts from leaving a turn stuck (card refusals, claude questions and mcp forms) #168. Error level matters because the renderer only shows Error notices. Codex's existing cancel_dialog was already visible through its Dialog callout, so it is unchanged.
  • Titled single and multi-select choices (oneOf, anyOf, items.anyOf) are choices answered with their values. Before, they fell back to a free-text answer.
  • A command approval always keeps a way to say no: Codex's cancel is added when no decline or cancel survives filtering.
  • Every question card now ends with Cancel, answered as the harness's cancel. Codex, Claude, ACP and OpenCode all handle it. With eight options, Cancel shares the last row, because Inline takes at most eight rows of buttons.
  • /stop with no turn running cancels open requests that wait on no turn, instead of replying "Nothing is running." A sub-agent's requests and asynchronous questions are left alone.

Wire and contract notes

  • No Inline protocol, proto or schema changes.
  • The Codex app-server wire is consumed as Codex sends it. Shapes were checked against codex-rs main 33b3f80a (2026-11-07), and pinned in a new contract fixture: crates/agent-bridge/tests/fixtures/harness/codex/mcp-tool-approval.json.
  • The bridge's own button callback payload (ActionData) gains a qx (Dismiss) variant. Only the bridge reads it.

Tests

  • Codex driver: the live repro shape (coolify manage_notifications); Allow, Allow for this session, Cancel; a card closed at turn end with a null turnId; a sub-agent registered from thread/started whose card closes with its turn; the argument bounds and cleaning; titled multi-select; command cards that can always say no; the unknown-thread notice.
  • Bridge: golden card blocks/fixtures/approval/codex-mcp-tool. Fault tests through the work actor: Allow answered once, a second press gets "no longer pending", Cancel answers its own card, a withdrawn card closes with no buttons and a late tap reaches nothing, question Cancel, and /stop with no turn leaving an asynchronous question and a turn-bound request open. An exactly-8-option question stays within 8 rows.
  • cargo test -p inline-agent-driver-codex -p inline-agent-bridge, cargo test -p inline-cli bridge and cargo clippy --all-targets on those crates all pass.

Left out (follow-ups)

  • The "Approve for me" default permission profile and the settings changes from bridge: acp parity, harness smoothness, ios agent blocks #153.
  • If serverRequest/resolved ever arrives before turn/completed, a withdrawn card would still read "Answered outside Inline". Codex sends it after the turn event (it goes through the thread listener), so this was not observed.
  • Not verified in the apps: whether every client draws the new Cancel button under a form (non-picker) card.

🤖 Generated with Claude Code

@morajabi
morajabi force-pushed the claude/codex-mcp-approvals-734f0b branch from 2078c3c to 2fc5274 Compare November 23, 2026 14:23
…prompt is left unanswerable

Codex asks to run an MCP tool with a message-only form elicitation
(empty requestedSchema, _meta.codex_approval_kind "mcp_tool_call"). Main
mapped it to a question with no fields: the chat showed only the message
and Codex waited until the turn was stopped.

- map message-only elicitations to approvals: a tool approval is a tool
  card (server · tool, arguments bounded and stripped of control and
  bidi-override characters) with the Codex TUI's choices (Allow, the
  remember options _meta.persist allows, Cancel with the user
  cancellation reason); other message-only requests get Allow/Deny/Cancel
- an elicitation with no turnId belongs to its thread's running turn, so
  its card closes when that turn ends or is interrupted
- a sub-agent's requests close with its own turn instead of later
  reading "answered outside Inline"
- register sub-agent threads from thread/started (parentThreadId), so a
  request that beats the spawn item is still shown; a request from a
  thread no session knows is refused with a "Request declined" notice in the chat
- titled single and multi-select choices (oneOf, anyOf, items.anyOf)
  are choices, answered with their values
- a command approval always offers a way to say no
- contract fixture for the mcp tool approval wire shape
…stop for turnless requests

- golden card fixture for a Codex MCP tool approval
- every question card ends with Cancel, answered as the harness's cancel
  (Codex, Claude, ACP and OpenCode all take it); with eight options it
  shares the last row, within Inline's eight-row limit
- /stop with no turn running cancels open requests that wait on no turn
  (not a sub-agent's, not an asynchronous question) instead of answering
  "Nothing is running."
- fault tests: a tool card answers once, Cancel answers its own card, a
  withdrawn card reaches nothing; question cancel and turnless stop
- bridge doc: Codex MCP tool cards, question Cancel, turnless /stop
@morajabi
morajabi force-pushed the claude/codex-mcp-approvals-734f0b branch from 2fc5274 to 28284f3 Compare November 23, 2026 15:17

This branch has not been deployed

No deployments
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.

1 participant