mirror of
https://github.com/openai/codex.git
synced 2026-11-11 21:10:39 +00:00
Add opt-in OTLP logging for final agent responses (#47649)
## What changed Add `otel.log_agent_responses`, disabled by default and requiring an OTLP HTTP or gRPC log exporter. Emit `codex.agent_response` for completed `final_answer` messages from main agents and spawned task agents, with session, turn, item, and available parent/root attribution. Strip memory citations from exported text, preserve the stored answer, and cap responses at 64 KiB on a UTF-8 character boundary. Include the original byte length and a truncation flag, and suppress duplicate item completions within each turn. Exclude commentary and non-task agents. ## Testing Extend configuration tests for default-off and explicit opt-in behavior, the agent execution test for main/subagent response attribution, and the log-buffer test for response-event exclusion. GitOrigin-RevId: eacda1150de2e6bac2c667d71b57214b0a086f1a
This commit is contained in:
@@ -601,6 +601,9 @@ pub struct OtelConfigToml {
|
||||
pub tool_result: codex_protocol::config_types::ToolResultLogConfig,
|
||||
/// Log user prompt in traces
|
||||
pub log_user_prompt: Option<bool>,
|
||||
/// Opt in to logging final main-agent and spawned-subagent responses to an OTLP log exporter.
|
||||
/// Defaults to false. Response text can be sensitive and is capped at 64 KiB.
|
||||
pub log_agent_responses: Option<bool>,
|
||||
|
||||
/// Mark traces with environment (dev, staging, prod, test). Defaults to dev.
|
||||
pub environment: Option<String>,
|
||||
@@ -626,6 +629,7 @@ pub struct OtelConfigToml {
|
||||
pub struct OtelConfig {
|
||||
pub tool_result: codex_protocol::config_types::ToolResultLogConfig,
|
||||
pub log_user_prompt: bool,
|
||||
pub log_agent_responses: bool,
|
||||
pub environment: String,
|
||||
pub exporter: OtelExporterKind,
|
||||
pub trace_exporter: OtelExporterKind,
|
||||
@@ -639,6 +643,7 @@ impl Default for OtelConfig {
|
||||
OtelConfig {
|
||||
tool_result: Default::default(),
|
||||
log_user_prompt: false,
|
||||
log_agent_responses: false,
|
||||
environment: DEFAULT_OTEL_ENVIRONMENT.to_owned(),
|
||||
exporter: OtelExporterKind::None,
|
||||
trace_exporter: OtelExporterKind::None,
|
||||
@@ -649,6 +654,17 @@ impl Default for OtelConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl OtelConfig {
|
||||
/// Response text requires a separate opt-in and an explicit OTLP log destination.
|
||||
pub fn agent_response_logging_enabled(&self) -> bool {
|
||||
self.log_agent_responses
|
||||
&& matches!(
|
||||
self.exporter,
|
||||
OtelExporterKind::OtlpHttp { .. } | OtelExporterKind::OtlpGrpc { .. }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone, PartialEq, Eq, Deserialize, JsonSchema)]
|
||||
#[serde(untagged)]
|
||||
pub enum Notifications {
|
||||
|
||||
Reference in New Issue
Block a user