mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Attribute command and plugin analytics to the invoking model (#45445)
## Why Command execution and plugin measurement events lack model and reasoning-effort labels. Attribution needs to reflect the step that invoked the command, even when model settings change before a background process finishes. ## What changed - Add `model_slug` and `reasoning_effort` to command execution and plugin measurement analytics. - Capture model context from resolved step settings and carry it through execution, approval, Guardian review, and plugin metrics collection. - Preserve the first command-start model context when subsequent start notifications arrive. - Keep the carried context out of serialized protocol items and generated schemas. ## Testing Extend analytics tests to cover model switches before invocation and during background execution, default reasoning effort, Guardian-denied commands, and repeated start notifications retaining the original model context. GitOrigin-RevId: af90e1c0d39bab625f2e89786085b61a9b96c0ce
This commit is contained in:
1 parent
b6a5d5bb14
commit
4d8eca1ff3
40 files changed
+355
-43
No files matched your search
@@ -701,6 +701,7 @@ impl Session {
|
||||
self.request_command_approval(
|
||||
ctx.review_context.turn(),
|
||||
ExecApprovalKind::Command,
|
||||
ctx.review_context.model_context(),
|
||||
ctx.call_id.clone(),
|
||||
/*approval_id*/ None,
|
||||
Some(environment_id.clone()),
|
||||
@@ -730,6 +731,7 @@ impl Session {
|
||||
self.request_command_approval(
|
||||
ctx.review_context.turn(),
|
||||
ExecApprovalKind::WriteStdin,
|
||||
ctx.review_context.model_context(),
|
||||
id.clone(),
|
||||
Some(approval_id.clone()),
|
||||
Some(environment_id.clone()),
|
||||
@@ -761,6 +763,7 @@ impl Session {
|
||||
self.request_command_approval(
|
||||
ctx.review_context.turn(),
|
||||
ExecApprovalKind::Command,
|
||||
ctx.review_context.model_context(),
|
||||
ctx.call_id.clone(),
|
||||
Some(approval_id.clone()),
|
||||
Some(environment_id.clone()),
|
||||
@@ -833,6 +836,7 @@ impl Session {
|
||||
self.request_command_approval(
|
||||
ctx.review_context.turn(),
|
||||
ExecApprovalKind::Command,
|
||||
ctx.review_context.model_context(),
|
||||
ctx.call_id.clone(),
|
||||
/*approval_id*/ None,
|
||||
Some(environment_id.clone()),
|
||||
|
||||
@@ -17,6 +17,7 @@ use codex_protocol::exec_output::ExecToolCallOutput;
|
||||
use codex_protocol::items::CommandExecutionItem;
|
||||
use codex_protocol::items::CommandExecutionStatus;
|
||||
use codex_protocol::items::FileChangeItem;
|
||||
use codex_protocol::items::ModelInvocationContext;
|
||||
use codex_protocol::items::TurnItem;
|
||||
use codex_protocol::openai_models::ModelInfo;
|
||||
use codex_protocol::parse_command::ParsedCommand;
|
||||
@@ -43,6 +44,7 @@ pub(super) fn truncate_rejection_message(message: &str) -> String {
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) struct ToolEventCtx<'a> {
|
||||
pub model_context: Option<&'a ModelInvocationContext>,
|
||||
pub session: &'a Session,
|
||||
pub turn: &'a TurnContext,
|
||||
/// Model captured by the step that issued this call, including delayed completion events.
|
||||
@@ -60,6 +62,7 @@ impl<'a> ToolEventCtx<'a> {
|
||||
turn_diff_tracker: Option<&'a SharedTurnDiffTracker>,
|
||||
) -> Self {
|
||||
Self {
|
||||
model_context: None,
|
||||
session,
|
||||
turn,
|
||||
model_info,
|
||||
@@ -168,6 +171,7 @@ async fn emit_exec_command_begin(ctx: ToolEventCtx<'_>, exec_input: &ExecCommand
|
||||
ctx.turn,
|
||||
&TurnItem::CommandExecution(CommandExecutionItem {
|
||||
id: ctx.call_id.to_string(),
|
||||
model_context: ctx.model_context.cloned(),
|
||||
plugin_id,
|
||||
script_path,
|
||||
process_id: exec_input.process_id.map(str::to_owned),
|
||||
@@ -581,6 +585,7 @@ async fn emit_exec_end(
|
||||
ctx.turn,
|
||||
TurnItem::CommandExecution(CommandExecutionItem {
|
||||
id: ctx.call_id.to_string(),
|
||||
model_context: ctx.model_context.cloned(),
|
||||
plugin_id,
|
||||
script_path,
|
||||
process_id: exec_input.process_id.map(str::to_owned),
|
||||
|
||||
Reference in new issue
Block a user