mirror of
https://github.com/openai/codex.git
synced 2026-10-20 17:38:45 +00:00
## Why Spawn failures can share an error kind and message despite different causes, such as execution and residency capacity limits. Telemetry needs enough detail to distinguish these failures without using error messages or correlation IDs as metric labels. ## What changed - Add `AgentErrorContext` annotations for capacity limits, registry rejections, runtime availability, and spawn stages. Preserve the first annotation so outer stages retain the more precise failure origin. - Add bounded `detail` and `error_kind` labels to spawn failure metrics, using `unknown` when no context is available. - Emit spawn failure trace events with these classifications and the call and turn IDs for both multi-agent versions. ## Testing Add tests for distinct capacity and registry failure contexts, preservation of manager, fork, and shutdown errors, and metric aggregation across different error messages and correlation IDs. Verify that annotations preserve existing error kinds and user-visible messages. GitOrigin-RevId: 5bbe3d32f6ce408622f38e559fddeab05b8ccb65
33 lines
998 B
Rust
33 lines
998 B
Rust
//! Bounded agent failure diagnostics, separate from error behavior and user-visible messages.
|
|
//! The first annotation wins so outer spawn stages preserve more precise failure origins.
|
|
|
|
use super::CodexErr;
|
|
|
|
/// A failure origin, or the spawn stage when no more precise origin is available.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, strum_macros::IntoStaticStr)]
|
|
#[strum(serialize_all = "snake_case")]
|
|
pub enum AgentErrorContext {
|
|
ExecutionCapacity,
|
|
ResidencyCapacity,
|
|
RegistryCapacity,
|
|
DuplicatePath,
|
|
NicknameUnavailable,
|
|
ManagerUnavailable,
|
|
RuntimeShutdown,
|
|
ForkHistory,
|
|
ChildStartup,
|
|
InputAdmission,
|
|
}
|
|
|
|
impl CodexErr {
|
|
/// Attach bounded diagnostics without replacing a more precise inner annotation.
|
|
pub fn with_agent_context(mut self, context: AgentErrorContext) -> Self {
|
|
self.agent_context.get_or_insert(context);
|
|
self
|
|
}
|
|
|
|
pub fn agent_context(&self) -> Option<AgentErrorContext> {
|
|
self.agent_context
|
|
}
|
|
}
|