Use captured step settings for tool planning and execution (#44242)

## Why

After a model change within a turn, tools could still use the turn's original model capabilities, output limits, and telemetry attribution.

## What changed

- Build each step's tool plan from its captured model settings.
- Use those settings for image support and detail, command and MCP output truncation, extension metadata, and tool telemetry.
- Preserve the issuing step's model for delayed command completion events while allowing later `write_stdin` calls to use their own step's output limits.

## Testing

Add regression coverage for model changes within a turn, including tool replanning, Code Mode execution, image handling, MCP tool and resource output limits, extension settings, and delayed command completion.

GitOrigin-RevId: ef991598e89a846889baf770a0c9e12e56886d5d
This commit is contained in:
Abhinav authored and copyberry committed 2026-09-09 17:45:37 +00:00
1 parent ed4ca07ba6
commit 205f3671e1
24 files changed
+1053 -241

No files matched your search

+4 -3
View File
@@ -207,7 +207,6 @@ impl McpHandler {
payload,
..
} = invocation;
let turn = Arc::clone(&step_context.turn);
let payload = match payload {
ToolPayload::Function { arguments } => arguments,
@@ -223,7 +222,7 @@ impl McpHandler {
.as_ref()
.and_then(codex_mcp::PreparedMcpCall::output_token_limit)
.map(TruncationPolicy::Tokens)
.unwrap_or(turn.model_info().truncation_policy.into());
.unwrap_or(step_context.settings.model_info.truncation_policy.into());
let started = Instant::now();
let result = handle_mcp_tool_call(
Arc::clone(&session),
@@ -243,7 +242,9 @@ impl McpHandler {
result: result.result,
tool_input: result.tool_input,
wall_time: started.elapsed(),
original_image_detail_supported: can_request_original_image_detail(turn.model_info()),
original_image_detail_supported: can_request_original_image_detail(
&step_context.settings.model_info,
),
truncation_policy,
}))
}