mirror of
https://github.com/openai/codex.git
synced 2026-11-25 15:24:26 +00:00
Track plugin metrics for background unified exec commands (#38276)
## Why Unified exec can yield while a command is still running. Plugin measurement collection must remain active until that background command exits, including when its item completion arrives after the turn has completed. ## What changed - Keep the plugin metrics sidecar with the stored process and let either the exit watcher or a poll that observes completion finalize it exactly once. - Retain completed turn analytics state while tool items are pending so late command completion events can be emitted without duplicating the turn event. ## Testing - Verify that a background command completed after its turn emits a command execution event and does not emit a second turn event. GitOrigin-RevId: ecf715b3e047aa29ca9a417d12d955257fed8557
This commit is contained in:
1 parent
cbb7e82a8b
commit
96e8afbfb8
8 files changed
+158
-8
No files matched your search
@@ -424,6 +424,7 @@ struct TurnState {
|
||||
steer_count: usize,
|
||||
tool_counts: TurnToolCounts,
|
||||
resource_skill_invocations: HashSet<String>,
|
||||
turn_event_emitted: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Hash, Eq, PartialEq)]
|
||||
@@ -1757,6 +1758,14 @@ impl AnalyticsReducer {
|
||||
);
|
||||
}
|
||||
self.item_review_summaries.remove(&key);
|
||||
if self
|
||||
.turns
|
||||
.get(¬ification.turn_id)
|
||||
.is_some_and(|turn_state| turn_state.turn_event_emitted)
|
||||
&& !self.has_pending_tool_items_for_turn(¬ification.turn_id)
|
||||
{
|
||||
self.turns.remove(¬ification.turn_id);
|
||||
}
|
||||
}
|
||||
ServerNotification::ItemGuardianApprovalReviewStarted(notification) => {
|
||||
let _ = notification;
|
||||
@@ -2128,6 +2137,9 @@ impl AnalyticsReducer {
|
||||
let Some(turn_state) = self.turns.get(turn_id) else {
|
||||
return;
|
||||
};
|
||||
if turn_state.turn_event_emitted {
|
||||
return;
|
||||
}
|
||||
if turn_state.thread_id.is_none()
|
||||
|| turn_state.num_input_images.is_none()
|
||||
|| turn_state.resolved_config.is_none()
|
||||
@@ -2179,7 +2191,19 @@ impl AnalyticsReducer {
|
||||
input.repo_hash = accepted_line_repo_hash_for_cwd(cwd.as_path()).await;
|
||||
out.extend(accepted_line_fingerprint_event_requests(input));
|
||||
}
|
||||
self.turns.remove(turn_id);
|
||||
if self.has_pending_tool_items_for_turn(turn_id) {
|
||||
if let Some(turn_state) = self.turns.get_mut(turn_id) {
|
||||
turn_state.turn_event_emitted = true;
|
||||
}
|
||||
} else {
|
||||
self.turns.remove(turn_id);
|
||||
}
|
||||
}
|
||||
|
||||
fn has_pending_tool_items_for_turn(&self, turn_id: &str) -> bool {
|
||||
self.tool_items_started_at_ms
|
||||
.keys()
|
||||
.any(|key| key.turn_id == turn_id)
|
||||
}
|
||||
|
||||
/// Resolve the parent connection lazily when a subagent fact arrives first.
|
||||
|
||||
Reference in new issue
Block a user