mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:25:04 +00:00
Track implicit executor skill invocations (#38074)
## What changed - Detect executor-owned skill document reads and script executions across native and URI-based working directories. - Match skills only within the active execution environment while preserving host skill detection for local commands. - Emit resource-backed implicit invocation events and deduplicate repeated accesses within a turn. ## Testing - Add unit coverage for document reads, script executions, and environment-scoped matching. - Add an integration test for environment selection, resource-backed analytics, and repeated-access deduplication. GitOrigin-RevId: f78a48c3a4766fe8775bd88926b45a76761f6af8
This commit is contained in:
1 parent
ba2fb48319
commit
a817d9424d
9 files changed
+351
-34
No files matched your search
@@ -0,0 +1,69 @@
|
||||
use super::*;
|
||||
use crate::catalog::SkillAuthority;
|
||||
use crate::catalog::SkillCatalog;
|
||||
use crate::catalog::SkillCatalogEntry;
|
||||
use crate::catalog::SkillPackageId;
|
||||
use crate::catalog::SkillResourceId;
|
||||
|
||||
fn detect_executor_skill(command: &str, environments: &[&str]) -> Option<SkillInvocation> {
|
||||
let skill_path = PathUri::parse("file:///skills/demo/SKILL.md").expect("valid skill URI");
|
||||
let catalog = SkillCatalog {
|
||||
entries: environments
|
||||
.iter()
|
||||
.map(|environment| {
|
||||
SkillCatalogEntry::new(
|
||||
SkillPackageId(format!("skill://{environment}/demo")),
|
||||
SkillAuthority::new(SkillSourceKind::Executor, *environment),
|
||||
format!("{environment}-skill"),
|
||||
"test skill",
|
||||
SkillResourceId::environment(
|
||||
format!("skill://{environment}/demo/SKILL.md"),
|
||||
*environment,
|
||||
skill_path.clone(),
|
||||
),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
warnings: Vec::new(),
|
||||
};
|
||||
let turn_store = ExtensionData::new("test-turn");
|
||||
turn_store.insert(ExecutorSkillsStepState(catalog));
|
||||
|
||||
detect_implicit_skill_invocation(
|
||||
&turn_store,
|
||||
"executor-a",
|
||||
command,
|
||||
&PathUri::parse("file:///skills").expect("valid workdir URI"),
|
||||
/*native_workdir*/ None,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detects_executor_skill_document_reads() {
|
||||
let invocation = detect_executor_skill("cat demo/SKILL.md", &["executor-a"])
|
||||
.expect("document read should identify the executor skill");
|
||||
|
||||
assert_eq!(invocation.skill_name, "executor-a-skill");
|
||||
assert!(matches!(
|
||||
invocation.location,
|
||||
SkillInvocationLocation::Resource { id, .. }
|
||||
if id == "skill://executor-a/demo/SKILL.md"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detects_executor_skill_script_runs() {
|
||||
let invocation = detect_executor_skill("python demo/scripts/run.py", &["executor-a"])
|
||||
.expect("script execution should identify the executor skill");
|
||||
|
||||
assert_eq!(invocation.skill_name, "executor-a-skill");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignores_matching_paths_from_other_environments() {
|
||||
let invocation = detect_executor_skill("cat demo/SKILL.md", &["executor-b", "executor-a"])
|
||||
.expect("matching path should resolve to the execution environment");
|
||||
|
||||
assert_eq!(invocation.skill_name, "executor-a-skill");
|
||||
assert!(detect_executor_skill("cat demo/SKILL.md", &["executor-b"]).is_none());
|
||||
}
|
||||
Reference in new issue
Block a user