mirror of
https://github.com/openai/codex.git
synced 2026-11-21 07:09:23 +00:00
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:
1 parent
ed4ca07ba6
commit
205f3671e1
24 files changed
+1053
-241
No files matched your search
@@ -239,7 +239,7 @@ pub(crate) async fn handle_mcp_tool_call(
|
||||
let status = if result.is_ok() { "ok" } else { "error" };
|
||||
let outcome = McpCallMetricOutcome::from_status(status);
|
||||
emit_mcp_call_metrics(
|
||||
turn_context.as_ref(),
|
||||
&step_context.session_telemetry,
|
||||
&outcome,
|
||||
&server,
|
||||
&tool_name,
|
||||
@@ -348,7 +348,7 @@ pub(crate) async fn handle_mcp_tool_call(
|
||||
let status = if result.is_ok() { "ok" } else { "error" };
|
||||
let outcome = McpCallMetricOutcome::from_status(status);
|
||||
emit_mcp_call_metrics(
|
||||
turn_context.as_ref(),
|
||||
&step_context.session_telemetry,
|
||||
&outcome,
|
||||
&server,
|
||||
&tool_name,
|
||||
@@ -489,7 +489,7 @@ async fn handle_approved_mcp_tool_call(
|
||||
.map(|(connector_id, action_name)| HostedFileUploadContext {
|
||||
connector_id: connector_id.clone(),
|
||||
action_name: action_name.clone(),
|
||||
model: turn_context.model_info().slug.clone(),
|
||||
model: step_context.settings.model_info.slug.clone(),
|
||||
});
|
||||
let rewritten_arguments = rewrite_mcp_tool_arguments_for_openai_files(
|
||||
sess,
|
||||
@@ -545,7 +545,7 @@ async fn handle_approved_mcp_tool_call(
|
||||
)
|
||||
.await;
|
||||
let result = sanitize_mcp_tool_result_for_model(
|
||||
&turn_context.model_info().input_modalities,
|
||||
&step_context.settings.model_info.input_modalities,
|
||||
Ok(result),
|
||||
)?;
|
||||
Ok(maybe_request_codex_apps_auth_elicitation(
|
||||
@@ -590,11 +590,11 @@ async fn handle_approved_mcp_tool_call(
|
||||
truncate_mcp_tool_result_for_event(&result),
|
||||
)
|
||||
.await;
|
||||
maybe_track_codex_app_used(sess, turn_context, &server, &metadata).await;
|
||||
maybe_track_codex_app_used(sess, step_context, &server, &metadata).await;
|
||||
|
||||
let outcome = mcp_call_metric_outcome(&result);
|
||||
emit_mcp_call_metrics(
|
||||
turn_context,
|
||||
&step_context.session_telemetry,
|
||||
&outcome,
|
||||
&server,
|
||||
&tool_name,
|
||||
@@ -1055,7 +1055,7 @@ async fn notify_mcp_tool_call_completed(
|
||||
|
||||
async fn maybe_track_codex_app_used(
|
||||
sess: &Session,
|
||||
turn_context: &TurnContext,
|
||||
step_context: &StepContext,
|
||||
server: &str,
|
||||
metadata: &McpToolApprovalMetadata,
|
||||
) {
|
||||
@@ -1075,8 +1075,9 @@ async fn maybe_track_codex_app_used(
|
||||
InvocationType::Implicit
|
||||
};
|
||||
|
||||
let turn_context = &step_context.turn;
|
||||
let tracking = build_track_events_context(
|
||||
turn_context.model_info().slug.clone(),
|
||||
step_context.settings.model_info.slug.clone(),
|
||||
sess.thread_id.to_string(),
|
||||
turn_context.sub_id.clone(),
|
||||
turn_context.originator.clone(),
|
||||
|
||||
Reference in new issue
Block a user