mirror of
https://github.com/openai/codex.git
synced 2026-11-30 07:38:11 +00:00
Track resource-backed skill invocations (#38066)
## What changed - Emit skill invocation analytics when a resource-backed skill is explicitly selected or its main resource is successfully read from the first page. - Preserve provider-supplied skill IDs and user scope when available, and derive a stable ID from the main resource otherwise. - Deduplicate repeated implicit reads of the same main resource within a turn. ## Testing - Extend the orchestrator skill integration test to cover explicit and implicit invocation events, stable fallback IDs, failed reads, and repeated-read deduplication. GitOrigin-RevId: 7d8453b31b5a2205847e65cda2c46183d6c97b45
This commit is contained in:
1 parent
104e25ac5a
commit
c8f673fddc
14 files changed
+311
-71
No files matched your search
@@ -1186,6 +1186,7 @@ impl Session {
|
||||
));
|
||||
let session_extension_data =
|
||||
codex_extension_api::ExtensionData::new(session_id.to_string());
|
||||
session_extension_data.insert(analytics_events_client.clone());
|
||||
let mcp_resource_client = Arc::new(McpResourceClient::new(Arc::clone(&mcp_runtime)));
|
||||
let extension_metrics =
|
||||
extension_metrics::from_session_telemetry(session_telemetry.clone());
|
||||
|
||||
+18
-13
@@ -3,6 +3,7 @@ use crate::session::session::Session;
|
||||
use crate::session::turn_context::TurnContext;
|
||||
use codex_analytics::InvocationType;
|
||||
use codex_analytics::SkillInvocation;
|
||||
use codex_analytics::SkillInvocationLocation;
|
||||
use codex_analytics::TrackEventsContext;
|
||||
use codex_analytics::build_track_events_context;
|
||||
use codex_extension_api::SkillInvocationInput;
|
||||
@@ -64,8 +65,10 @@ pub(crate) fn emit_explicit_skill_invocations(
|
||||
.iter()
|
||||
.map(|skill| SkillInvocation {
|
||||
skill_name: skill.name.clone(),
|
||||
skill_scope: skill.scope,
|
||||
skill_path: skill.path_to_skills_md.to_path_buf(),
|
||||
location: SkillInvocationLocation::Host {
|
||||
path: skill.path_to_skills_md.to_path_buf(),
|
||||
scope: skill.scope,
|
||||
},
|
||||
plugin_id: skill.plugin_id.clone(),
|
||||
remote_plugin_id: skill.remote_plugin_id.clone(),
|
||||
invocation_type: InvocationType::Explicit,
|
||||
@@ -89,21 +92,23 @@ pub(crate) async fn maybe_emit_implicit_skill_invocation(
|
||||
) else {
|
||||
return;
|
||||
};
|
||||
let invocation = SkillInvocation {
|
||||
skill_name: candidate.name,
|
||||
skill_scope: candidate.scope,
|
||||
skill_path: candidate.path_to_skills_md.to_path_buf(),
|
||||
plugin_id: candidate.plugin_id,
|
||||
remote_plugin_id: candidate.remote_plugin_id,
|
||||
invocation_type: InvocationType::Implicit,
|
||||
};
|
||||
let skill_scope = match invocation.skill_scope {
|
||||
let skill_scope = match candidate.scope {
|
||||
SkillScope::User => "user",
|
||||
SkillScope::Repo => "repo",
|
||||
SkillScope::System => "system",
|
||||
SkillScope::Admin => "admin",
|
||||
};
|
||||
let skill_path = invocation.skill_path.to_string_lossy();
|
||||
let skill_path = candidate.path_to_skills_md.to_string_lossy().into_owned();
|
||||
let invocation = SkillInvocation {
|
||||
skill_name: candidate.name,
|
||||
location: SkillInvocationLocation::Host {
|
||||
path: candidate.path_to_skills_md.to_path_buf(),
|
||||
scope: candidate.scope,
|
||||
},
|
||||
plugin_id: candidate.plugin_id,
|
||||
remote_plugin_id: candidate.remote_plugin_id,
|
||||
invocation_type: InvocationType::Implicit,
|
||||
};
|
||||
let skill_name = invocation.skill_name.clone();
|
||||
let seen_key = format!("{skill_scope}:{skill_path}:{skill_name}");
|
||||
let inserted = {
|
||||
@@ -125,7 +130,7 @@ pub(crate) async fn maybe_emit_implicit_skill_invocation(
|
||||
thread_store: &sess.services.thread_extension_data,
|
||||
turn_store: turn_context.extension_data.as_ref(),
|
||||
turn_id: turn_context.sub_id.as_str(),
|
||||
skill_resource: skill_path.as_ref(),
|
||||
skill_resource: skill_path.as_str(),
|
||||
kind: SkillInvocationKind::Implicit,
|
||||
})
|
||||
.await;
|
||||
|
||||
Reference in new issue
Block a user