Skip to content

Plumb MCP turn metadata through _meta#15190

Merged
nicholasclark-openai merged 14 commits intomainfrom
nicholasclark/tool-call-task-headers-_meta
Mar 19, 2026
Merged

Plumb MCP turn metadata through _meta#15190
nicholasclark-openai merged 14 commits intomainfrom
nicholasclark/tool-call-task-headers-_meta

Conversation

@nicholasclark-openai
Copy link
Contributor

@nicholasclark-openai nicholasclark-openai commented Mar 19, 2026

Summary

Some background. We're looking to instrument GA turns end to end. Right now a big gap is grouping mcp tool calls with their codex sessions. We send session id and turn id headers to the responses call but not the mcp/wham calls.

Ideally we could pass the args as headers like with responses, but given the setup of the rmcp client, we can't send as headers without either changing the rmcp package upstream to allow per request headers or introducing a mutex which break concurrency. An earlier attempt made the assumption that we had 1 client per thread, which allowed us to set headers at the start of a turn. @pakrym mentioned that this assumption might break in the near future.

So the solution now is to package the turn metadata/session id into the _meta field in the post body and pull out in codex-backend.

  • send turn metadata to MCP servers via tools/call _meta instead of assuming per-thread request headers on shared clients
  • preserve the existing _codex_apps metadata while adding x-codex-turn-metadata for all MCP tool calls
  • extend tests to cover both custom MCP servers and the codex apps search flow

@nicholasclark-openai nicholasclark-openai marked this pull request as draft March 19, 2026 16:34
Co-authored-by: Codex <noreply@openai.com>
Base automatically changed from revert-15011-nicholasclark/tool-call-task-headers to main March 19, 2026 17:38

#[allow(clippy::too_many_arguments)]
fn make_turn_context(
conversation_id: ThreadId,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to pass along session id as well to get the full picture

Co-authored-by: Codex <noreply@openai.com>
@nicholasclark-openai nicholasclark-openai marked this pull request as ready for review March 19, 2026 18:35
@nicholasclark-openai nicholasclark-openai enabled auto-merge (squash) March 19, 2026 21:56
@nicholasclark-openai nicholasclark-openai merged commit 2bee37f into main Mar 19, 2026
33 checks passed
@nicholasclark-openai nicholasclark-openai deleted the nicholasclark/tool-call-task-headers-_meta branch March 19, 2026 22:05
@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants