mirror of
https://github.com/openai/codex.git
synced 2026-11-16 06:54:36 +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
@@ -20,6 +20,7 @@ mod review_session;
|
||||
mod reviewer_config;
|
||||
mod runtime;
|
||||
|
||||
use codex_protocol::items::ModelInvocationContext;
|
||||
use std::sync::Arc;
|
||||
|
||||
use codex_protocol::config_types::ApprovalsReviewer;
|
||||
@@ -82,6 +83,7 @@ pub(crate) struct GuardianReviewContext {
|
||||
pub(crate) parent_response_id: Option<String>,
|
||||
turn: Arc<TurnContext>,
|
||||
environments: TurnEnvironmentSnapshot,
|
||||
// Model and reasoning inputs are carried for the follow-up Guardian and V2 migrations.
|
||||
pub(crate) model_info: Arc<ModelInfo>,
|
||||
pub(crate) reasoning_effort: Option<ReasoningEffort>,
|
||||
pub(crate) reasoning_summary: ReasoningSummary,
|
||||
@@ -91,6 +93,17 @@ pub(crate) struct GuardianReviewContext {
|
||||
}
|
||||
|
||||
impl GuardianReviewContext {
|
||||
pub(crate) fn model_context(&self) -> ModelInvocationContext {
|
||||
ModelInvocationContext {
|
||||
model_slug: self.model_info.slug.clone(),
|
||||
reasoning_effort: self
|
||||
.reasoning_effort
|
||||
.as_ref()
|
||||
.or(self.model_info.default_reasoning_level.as_ref())
|
||||
.map(ToString::to_string),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn from_resolved_settings(
|
||||
turn: Arc<TurnContext>,
|
||||
settings: &ResolvedStepSettings,
|
||||
|
||||
@@ -44,6 +44,7 @@ impl ReviewHost for super::super::runtime::ReviewRuntime {
|
||||
Ok(request) => request.clone(),
|
||||
Err(decision) => return Err(decision),
|
||||
};
|
||||
let model_context = context.model_context();
|
||||
let turn = Arc::clone(context.turn());
|
||||
let GuardianReviewOptions {
|
||||
plugin_attribution_override,
|
||||
@@ -101,6 +102,7 @@ impl ReviewHost for super::super::runtime::ReviewRuntime {
|
||||
reviewed_action: guardian_reviewed_action(&request),
|
||||
action: guardian_assessment_action(&request),
|
||||
review_reason,
|
||||
model_context,
|
||||
});
|
||||
session
|
||||
.send_event(
|
||||
|
||||
Reference in new issue
Block a user