mirror of
https://github.com/openai/codex.git
synced 2026-06-01 19:02:59 +00:00
Add model and reasoning effort to MCP turn metadata (#21219)
## Why - Similar change as https://github.com/openai/codex/pull/19473. - Without change: MCP tool calls receive `_meta["x-codex-turn-metadata"]` with `session_id`, `turn_id`, and `turn_started_at_unix_ms`. - Issue: MCP servers may want the model and reasoning effort to better understand tool-call behavior and latency relative to turn start. ## What Changed - With change: MCP turn metadata now includes `model` and `reasoning_effort`, propagated in `_meta["x-codex-turn-metadata"]`. - Normal `/responses` turn metadata headers are unchanged. ## Verification - `codex-rs/core/src/mcp_tool_call_tests.rs` - `codex-rs/core/src/turn_metadata_tests.rs` - `codex-rs/core/tests/suite/search_tool.rs`
This commit is contained in:
@@ -570,6 +570,7 @@ async fn tool_search_returns_deferred_tools_without_follow_up_tool_injection() -
|
||||
|
||||
let requests = mock.requests();
|
||||
assert_eq!(requests.len(), 3);
|
||||
let first_request_body = requests[0].body_json();
|
||||
|
||||
let apps_tool_call = server
|
||||
.received_requests()
|
||||
@@ -604,6 +605,22 @@ async fn tool_search_returns_deferred_tools_without_follow_up_tool_injection() -
|
||||
.is_some_and(|turn_id| !turn_id.is_empty()),
|
||||
"apps tools/call should include turn metadata turn_id: {apps_tool_call:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
apps_tool_call
|
||||
.pointer("/params/_meta/x-codex-turn-metadata/model")
|
||||
.and_then(Value::as_str),
|
||||
Some("gpt-5.4")
|
||||
);
|
||||
let first_request_reasoning_effort = first_request_body
|
||||
.pointer("/reasoning/effort")
|
||||
.and_then(Value::as_str)
|
||||
.expect("first response request should include reasoning effort");
|
||||
assert_eq!(
|
||||
apps_tool_call
|
||||
.pointer("/params/_meta/x-codex-turn-metadata/reasoning_effort")
|
||||
.and_then(Value::as_str),
|
||||
Some(first_request_reasoning_effort)
|
||||
);
|
||||
let mcp_turn_started_at_unix_ms = apps_tool_call
|
||||
.pointer("/params/_meta/x-codex-turn-metadata/turn_started_at_unix_ms")
|
||||
.and_then(Value::as_i64)
|
||||
@@ -626,7 +643,6 @@ async fn tool_search_returns_deferred_tools_without_follow_up_tool_injection() -
|
||||
Some(mcp_turn_started_at_unix_ms)
|
||||
);
|
||||
|
||||
let first_request_body = requests[0].body_json();
|
||||
let first_request_tools = tool_names(&first_request_body);
|
||||
assert!(
|
||||
first_request_tools
|
||||
|
||||
Reference in New Issue
Block a user