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:
rphilizaire-openai authored and copyberry committed 2026-08-11 21:09:29 +00:00
1 parent ba2fb48319
commit a817d9424d
9 files changed
+351 -34

No files matched your search

@@ -1,7 +1,9 @@
use codex_exec_server::LOCAL_ENVIRONMENT_ID;
use codex_protocol::models::ShellCommandToolCallParams;
use codex_tools::ShellCommandBackendConfig;
use codex_tools::ToolName;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_path_uri::PathUri;
use crate::exec::ExecCapturePolicy;
use crate::exec::ExecParams;
@@ -208,7 +210,9 @@ impl ShellCommandHandler {
session.as_ref(),
turn.as_ref(),
&params.command,
&cwd,
&PathUri::from_abs_path(&cwd),
Some(&cwd),
LOCAL_ENVIRONMENT_ID,
)
.await;
let prefix_rule = params.prefix_rule.clone();
@@ -191,16 +191,15 @@ impl ExecCommandHandler {
let sandbox_permissions =
resolve_sandbox_permissions(args.sandbox_permissions, args.justification.as_deref())?;
let hook_command = args.cmd.clone();
// TODO(anp) wire PathUri through implicit skills instead of skipping on foreign paths
if let Some(native_cwd) = native_cwd.as_ref() {
maybe_emit_implicit_skill_invocation(
session.as_ref(),
context.step_context.turn.as_ref(),
&hook_command,
native_cwd,
)
.await;
}
maybe_emit_implicit_skill_invocation(
session.as_ref(),
context.step_context.turn.as_ref(),
&hook_command,
&cwd,
native_cwd.as_ref(),
&turn_environment.environment_id,
)
.await;
let shell_mode =
shell_mode_for_environment(&turn.unified_exec_shell_mode, environment.as_ref());
// Remote environments may use a different OS and must build commands with their native