mirror of
https://github.com/openai/codex.git
synced 2026-10-20 17:38:45 +00:00
## What changed Emit `codex.skill_invocation` logs for explicit skill injection and detected implicit use, including skill-tool reads. Include skill name, invocation type, conversation, turn, model, and client metadata, plus scope, plugin ID, and ChatGPT user and account IDs when available. Exclude skill contents, resource paths, email addresses, prompts, and tool payloads. Use the existing OTEL log exporter without an additional opt-in; `otel.exporter = "none"` continues to export no logs. Document the event fields, exporter configuration, and detection semantics in `codex-rs/otel/README.md`. GitOrigin-RevId: 0f9c492c3f224455f3de3660be89692d776c1951
62 lines
2.2 KiB
Rust
62 lines
2.2 KiB
Rust
//! Exports skill-use metadata without skill contents, filesystem paths, or tool payloads.
|
|
//! Detection belongs to the caller; an invocation does not imply successful task completion.
|
|
|
|
use crate::SessionTelemetry;
|
|
use crate::events::shared::timestamp;
|
|
use crate::targets::OTEL_LOG_ONLY_TARGET;
|
|
use codex_protocol::protocol::SkillScope;
|
|
|
|
/// How Codex detected the skill's use.
|
|
pub enum SkillInvocationType {
|
|
Explicit,
|
|
Implicit,
|
|
}
|
|
|
|
/// Metadata for a detected skill invocation. Never include skill contents or resource paths.
|
|
pub struct SkillInvocationEvent<'a> {
|
|
pub turn_id: &'a str,
|
|
pub skill_name: &'a str,
|
|
pub scope: Option<SkillScope>,
|
|
pub plugin_id: Option<&'a str>,
|
|
pub invocation_type: SkillInvocationType,
|
|
}
|
|
|
|
impl SessionTelemetry {
|
|
pub fn with_user_id(mut self, user_id: Option<String>) -> Self {
|
|
self.metadata.user_id = user_id;
|
|
self
|
|
}
|
|
|
|
pub fn skill_invocation(&self, event: SkillInvocationEvent<'_>) {
|
|
let invocation_type = match event.invocation_type {
|
|
SkillInvocationType::Explicit => "explicit",
|
|
SkillInvocationType::Implicit => "implicit",
|
|
};
|
|
let scope = event.scope.map(|scope| match scope {
|
|
SkillScope::User => "user",
|
|
SkillScope::Repo => "repo",
|
|
SkillScope::System => "system",
|
|
SkillScope::Admin => "admin",
|
|
});
|
|
tracing::event!(
|
|
name: "codex.skill_invocation",
|
|
target: OTEL_LOG_ONLY_TARGET,
|
|
tracing::Level::INFO,
|
|
event.name = "codex.skill_invocation",
|
|
event.timestamp = %timestamp(),
|
|
conversation.id = %self.metadata.conversation_id,
|
|
turn.id = event.turn_id,
|
|
user.id = self.metadata.user_id.as_deref(),
|
|
user.account_id = self.metadata.account_id.as_deref(),
|
|
skill.name = event.skill_name,
|
|
skill.scope = scope,
|
|
skill.plugin_id = event.plugin_id,
|
|
skill.invocation_type = invocation_type,
|
|
model = %self.metadata.model,
|
|
app.version = self.metadata.app_version,
|
|
originator = %self.metadata.originator,
|
|
auth_mode = self.metadata.auth_mode.as_deref(),
|
|
);
|
|
}
|
|
}
|