mirror of
https://github.com/openai/codex.git
synced 2026-10-26 18:38:47 +00:00
Tag tool registration metrics with effective incremental tools mode (#55692)
## What changed Add an `incremental_tools` attribute to `codex.tools.registered` using the effective mode for the current sampling request. Compute the mode once and reuse it for registration metrics and prompt construction across transport retries. ## Testing Extend integration tests to verify the attribute for incremental and non-incremental requests, including when the feature flag is enabled but the Responses API does not support incremental tools. Assert registration sample counts and retain coverage that stream retries do not duplicate registration metrics. GitOrigin-RevId: e5b7a1075fe722ef6bdf900ae07e2b1b06aecfb5
This commit is contained in:
@@ -1742,7 +1742,14 @@ async fn run_sampling_request(
|
||||
Arc::clone(&turn_diff_tracker),
|
||||
);
|
||||
let max_retries = turn_context.provider.info().stream_max_retries();
|
||||
record_registration_metrics(&step_context.tool_router, &step_context.session_telemetry);
|
||||
let incremental_tools = sess
|
||||
.current_window_uses_incremental_tools(&step_context)
|
||||
.await;
|
||||
record_registration_metrics(
|
||||
&step_context.tool_router,
|
||||
&step_context.session_telemetry,
|
||||
incremental_tools,
|
||||
);
|
||||
let mut retry_state = ResponsesStreamRetryState::default();
|
||||
let mut initial_input = Some(input);
|
||||
let mut original_input = None;
|
||||
@@ -1765,8 +1772,7 @@ async fn run_sampling_request(
|
||||
prompt_input,
|
||||
step_context.as_ref(),
|
||||
base_instructions.clone(),
|
||||
sess.current_window_uses_incremental_tools(&step_context)
|
||||
.await,
|
||||
incremental_tools,
|
||||
);
|
||||
let responses_metadata = sess
|
||||
.responses_metadata(step_context.as_ref(), CodexResponsesRequestKind::Turn)
|
||||
|
||||
@@ -395,7 +395,11 @@ impl ToolRouter {
|
||||
|
||||
/// Records the registered inventory once per sampling request, before transport retries.
|
||||
/// Registrations do not imply model visibility or reachability; hosted tools are excluded.
|
||||
pub(crate) fn record_registration_metrics(router: &ToolRouter, telemetry: &SessionTelemetry) {
|
||||
pub(crate) fn record_registration_metrics(
|
||||
router: &ToolRouter,
|
||||
telemetry: &SessionTelemetry,
|
||||
incremental_tools: bool,
|
||||
) {
|
||||
let mut direct = 0usize;
|
||||
let mut direct_model_only = 0usize;
|
||||
let mut deferred = 0usize;
|
||||
@@ -418,6 +422,7 @@ pub(crate) fn record_registration_metrics(router: &ToolRouter, telemetry: &Sessi
|
||||
ToolMode::CodeMode => "code_mode",
|
||||
ToolMode::CodeModeOnly => "code_mode_only",
|
||||
};
|
||||
let incremental_tools = if incremental_tools { "true" } else { "false" };
|
||||
for (exposure, count) in [
|
||||
(EXPOSURE_DIRECT, direct),
|
||||
(EXPOSURE_DIRECT_MODEL_ONLY, direct_model_only),
|
||||
@@ -430,7 +435,11 @@ pub(crate) fn record_registration_metrics(router: &ToolRouter, telemetry: &Sessi
|
||||
TOOL_REGISTRATIONS_METRIC,
|
||||
i64::try_from(count).unwrap_or(i64::MAX),
|
||||
TOOL_REGISTRATIONS_METRIC_BUCKETS,
|
||||
&[("exposure", exposure), ("tool_mode", tool_mode)],
|
||||
&[
|
||||
("exposure", exposure),
|
||||
("tool_mode", tool_mode),
|
||||
("incremental_tools", incremental_tools),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user