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

+1 -5
View File
@@ -13,7 +13,6 @@ use crate::hook_runtime::PreCompactHookOutcome;
use crate::hook_runtime::run_post_compact_hooks;
use crate::hook_runtime::run_pre_compact_hooks;
use crate::responses_metadata::CodexResponsesMetadata;
use crate::responses_metadata::CodexResponsesRequestKind;
use crate::responses_metadata::CompactionTurnMetadata;
use crate::session::RequestEffortUsage;
use crate::session::session::Session;
@@ -258,10 +257,7 @@ async fn run_compact_task_inner_impl(
// request tracking)
// survives retries within this compact turn.
let responses_metadata = sess
.responses_metadata(
turn_context.as_ref(),
CodexResponsesRequestKind::Compaction(compaction_metadata),
)
.compaction_responses_metadata(turn_context.as_ref(), compaction_metadata)
.await;
let compaction_response_id = loop {