Use captured step settings for request metadata and tool hooks (#45248)

## Why

Model and reasoning effort updates during a turn can leave request metadata and tool hooks reporting the turn's initial settings. Metadata should describe the step that issued the request or tool call.

## What changed

- Share captured execution metadata across Responses, MCP, and extension tool calls, including model, reasoning effort, and automatic review and Node REPL flags.
- Build Responses tool inventory metadata from the issuing step's finalized tool router. Attach the finalized inventory separately for remote compaction.
- Use captured step settings for pre- and post-tool hooks, and captured review settings for permission-request hooks.

## Testing

Add and extend regression tests for model and effort changes during a turn, MCP metadata, pre-tool hook model attribution, captured review flags, and tool inventory matching the issuing request.

GitOrigin-RevId: 9dee46a8b4839de8b434cdad4ed441cc0bb6ff9b
This commit is contained in:
Abhinav authored and copyberry committed 2026-09-13 15:47:59 +00:00
1 parent 36f0dbe796
commit 16537b20a5
20 files changed
+545 -255

No files matched your search

+4 -6
View File
@@ -20,7 +20,7 @@ use crate::tools::hook_names::HookToolName;
use crate::tools::lifecycle::process_mcp_tool_result;
use crate::tools::sandboxing::ApprovalAction;
use crate::tools::sandboxing::ToolError;
use crate::turn_metadata::McpTurnMetadataContext;
use crate::turn_metadata::ExecutionMetadata;
use codex_analytics::AppInvocation;
use codex_analytics::InvocationType;
use codex_analytics::build_track_events_context;
@@ -1252,11 +1252,9 @@ fn build_mcp_tool_call_request_meta(
if let Some(turn_metadata) = step_context
.turn
.turn_metadata_state
.current_meta_value_for_mcp_request(McpTurnMetadataContext {
model: step_context.settings.model_info.slug.as_str(),
reasoning_effort: step_context.settings.effective_reasoning_effort(),
node_repl_disabled: step_context.settings.model_info.node_repl_disabled,
})
.current_meta_value_for_mcp_request(ExecutionMetadata::from_settings(
&step_context.settings,
))
{
request_meta.insert(
crate::X_CODEX_TURN_METADATA_HEADER.to_string(),