Skip to content

Add user_input_requested_during_turn to MCP turn metadata#22237

Merged
mchen-oai merged 2 commits into
mainfrom
mchen/mcp_user_input_requested_during_turn_metadata
May 15, 2026
Merged

Add user_input_requested_during_turn to MCP turn metadata#22237
mchen-oai merged 2 commits into
mainfrom
mchen/mcp_user_input_requested_during_turn_metadata

Conversation

@mchen-oai
Copy link
Copy Markdown
Contributor

@mchen-oai mchen-oai commented May 12, 2026

Why

  • Similar change as Add model and reasoning effort to MCP turn metadata #21219
  • Without change: MCP tool calls receive _meta["x-codex-turn-metadata"] with various key values.
  • Issue: MCP servers currently do not know if user input was requested during the turn (Ex: Model decides to prompt the user for approval mid-turn before making a possibly risky tool call). MCP servers may want to know this when tracking latency metrics because these instances are inflated.

What Changed

  • With change: MCP turn metadata now includes user_input_requested_during_turn when a model-visible request_user_input call happened earlier in the turn, propagated in _meta["x-codex-turn-metadata"].
  • mark_turn_user_input_requested() is called when user input is requested through either MCP elicitation (mcp.rs) or the request_user_input tool (mod.rs).
  • MCP tool call _meta is now built immediately before execution (mcp_tool_call.rs) so user input requested earlier in the same turn, including within the same tool call via elicitation, is reflected in the metadata.
  • Normal /responses turn metadata headers are unchanged.

Verification

  • codex-rs/core/src/session/mcp_tests.rs
  • codex-rs/core/src/tools/handlers/request_user_input_tests.rs
  • codex-rs/core/src/turn_metadata_tests.rs
  • codex-rs/core/tests/suite/search_tool.rs

@mchen-oai mchen-oai changed the title Add user_input_requested_during_turn to MCP turn metadata Add user_input_requested_during_turn to MCP turn metadata May 12, 2026
@mchen-oai mchen-oai force-pushed the mchen/mcp_user_input_requested_during_turn_metadata branch from b36c34e to 45eb23b Compare May 12, 2026 02:52
@mchen-oai mchen-oai force-pushed the mchen/mcp_user_input_requested_during_turn_metadata branch 3 times, most recently from cb1ea1f to cbd6fe0 Compare May 12, 2026 03:40
@mchen-oai mchen-oai marked this pull request as ready for review May 12, 2026 03:47
@mchen-oai mchen-oai requested a review from a team as a code owner May 12, 2026 03:47
@mchen-oai mchen-oai requested a review from owenlin0 May 12, 2026 03:48
@mchen-oai mchen-oai force-pushed the mchen/mcp_user_input_requested_during_turn_metadata branch 4 times, most recently from 23a536b to 0386088 Compare May 12, 2026 15:21
@mchen-oai mchen-oai force-pushed the mchen/mcp_user_input_requested_during_turn_metadata branch 2 times, most recently from 6ae5307 to 4362a82 Compare May 14, 2026 14:03
Comment thread codex-rs/core/tests/suite/mcp_turn_metadata.rs Outdated
@mchen-oai mchen-oai force-pushed the mchen/mcp_user_input_requested_during_turn_metadata branch 2 times, most recently from ccb38a0 to 45a23ce Compare May 15, 2026 00:52
@mchen-oai mchen-oai force-pushed the mchen/mcp_user_input_requested_during_turn_metadata branch from 45a23ce to 88ea41c Compare May 15, 2026 01:06
@mchen-oai mchen-oai enabled auto-merge (squash) May 15, 2026 01:08
@mchen-oai mchen-oai merged commit 10cf1f7 into main May 15, 2026
31 checks passed
@mchen-oai mchen-oai deleted the mchen/mcp_user_input_requested_during_turn_metadata branch May 15, 2026 01:26
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants