mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Add OpenTelemetry for subagent lifecycles (#62567)
## Why Correlating a subagent's creation, turn attempts, and stop requests helps explain what happened when those actions span workers. ## What changed - Emit structured events and counters for successful spawns and accepted `close_agent` and `interrupt_agent` calls. Count accepted stops even when the target is already idle or unloaded. - Track initial, follow-up, and resumed turn attempts for spawned subagents. Record each start and at most one outcome per attempt: completed, failed, interrupted, or suspended. - Use thread, turn, and call IDs to correlate structured events while keeping those IDs out of metric labels. ## Testing Add coverage for lifecycle counts, duplicate outcomes, stop handling, and event correlation across workers. Improve the Windows elevated sandbox test for an approved `git pull` by provisioning the sandbox before the turn and reporting setup or launch failures with diagnostics. GitOrigin-RevId: bc1190302e1dffbdd79c7ac984b6debe1dac4a65
This commit is contained in:
@@ -81,6 +81,7 @@ use serde_json::Map;
|
||||
use serde_json::Value;
|
||||
use serde_with::serde_as;
|
||||
use strum_macros::Display;
|
||||
use strum_macros::IntoStaticStr;
|
||||
use tokio::sync::oneshot;
|
||||
use tokio::sync::watch;
|
||||
use tracing::error;
|
||||
@@ -2082,8 +2083,11 @@ impl From<SubAgentActivityEvent> for EventMsg {
|
||||
}
|
||||
|
||||
/// Agent lifecycle status, derived from emitted events.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS, Default)]
|
||||
#[derive(
|
||||
Debug, Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS, Default, IntoStaticStr,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
#[ts(rename_all = "snake_case")]
|
||||
pub enum AgentStatus {
|
||||
/// Agent is waiting for initialization.
|
||||
@@ -2113,8 +2117,9 @@ pub enum NonSteerableTurnKind {
|
||||
}
|
||||
|
||||
/// Codex errors that we expose to clients.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, JsonSchema, TS, IntoStaticStr)]
|
||||
#[schemars(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
#[ts(rename_all = "snake_case")]
|
||||
pub enum CodexErrorInfo {
|
||||
ContextWindowExceeded,
|
||||
@@ -4733,8 +4738,9 @@ pub struct TurnAbortedEvent {
|
||||
pub duration_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS, IntoStaticStr)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum TurnAbortReason {
|
||||
Interrupted,
|
||||
Replaced,
|
||||
|
||||
Reference in New Issue
Block a user