mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Collect plugin metrics from remote executors (#38283)
## What changed - Resolve manifest-declared metric operations against the executor filesystem for remote plugin commands. - Create the measurement sidecar in an executor-native, owner-private temporary directory, stream its bounded output back for validation, and clean up the directory afterward. - Extend the exec-server protocol with the executor temporary directory and atomic private-directory creation. ## Testing - Cover remote unified-exec measurements for foreground and background commands. - Verify private directories use owner-only permissions on Unix and fail closed on unsupported platforms. GitOrigin-RevId: dbbd0a84717b91237fc5728e510e18994eb46dd4
This commit is contained in:
1 parent
1e71e35df6
commit
9579479d28
18 files changed
+416
-82
No files matched your search
@@ -11,6 +11,7 @@ pub(crate) mod zsh_fork_backend;
|
||||
use crate::exec::ExecCapturePolicy;
|
||||
use crate::guardian::GuardianNetworkAccessTrigger;
|
||||
use crate::plugins::metrics::finish_and_track_measurements;
|
||||
use crate::plugins::metrics::sidecar_for_command;
|
||||
use crate::sandboxing::ExecOptions;
|
||||
use crate::sandboxing::SandboxPermissions;
|
||||
use crate::sandboxing::execute_env;
|
||||
@@ -212,15 +213,14 @@ impl ToolRuntime<ShellRequest, ExecToolCallOutput> for ShellRuntime {
|
||||
managed_network_for_sandbox_permissions(req.network.as_ref(), sandbox_permissions);
|
||||
let mut env = exec_env_for_sandbox_permissions(&req.env, sandbox_permissions);
|
||||
let explicit_env_overrides = req.explicit_env_overrides.clone();
|
||||
let metrics_sidecar = (!req.turn_environment.environment.is_remote()
|
||||
&& ctx.session.services.analytics_events_client.is_enabled())
|
||||
.then(|| {
|
||||
ctx.step_context
|
||||
.turn
|
||||
.plugin_metrics_operation_for_command(&req.command, &req.cwd)
|
||||
})
|
||||
.flatten()
|
||||
.and_then(PluginMetricsSidecar::create);
|
||||
let cwd = PathUri::from_abs_path(&req.cwd);
|
||||
let metrics_sidecar = sidecar_for_command(
|
||||
ctx,
|
||||
&req.command,
|
||||
&cwd,
|
||||
req.turn_environment.environment.as_ref(),
|
||||
)
|
||||
.await;
|
||||
if let Some(sidecar) = metrics_sidecar.as_ref() {
|
||||
sidecar.install_output_env(&mut env);
|
||||
}
|
||||
@@ -320,7 +320,8 @@ impl ToolRuntime<ShellRequest, ExecToolCallOutput> for ShellRuntime {
|
||||
&ctx.session,
|
||||
&ctx.step_context.turn,
|
||||
&ctx.call_id,
|
||||
);
|
||||
)
|
||||
.await;
|
||||
Ok(out)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::exec::ExecExpiration;
|
||||
use crate::guardian::GUARDIAN_REVIEW_TIMEOUT;
|
||||
use crate::guardian::GuardianNetworkAccessTrigger;
|
||||
use crate::guardian::routes_approval_to_guardian;
|
||||
use crate::plugins::metrics::sidecar_for_command;
|
||||
use crate::sandboxing::ExecOptions;
|
||||
use crate::sandboxing::ExecServerEnvConfig;
|
||||
use crate::sandboxing::SandboxPermissions;
|
||||
@@ -337,16 +338,13 @@ impl<'a> ToolRuntime<UnifiedExecRequest, UnifiedExecAttempt> for UnifiedExecRunt
|
||||
None => (env, None, None),
|
||||
};
|
||||
let explicit_env_overrides = req.explicit_env_overrides.clone();
|
||||
let metrics_sidecar = (!environment_is_remote
|
||||
&& ctx.session.services.analytics_events_client.is_enabled())
|
||||
.then(|| {
|
||||
let cwd = req.cwd.to_abs_path().ok()?;
|
||||
ctx.step_context
|
||||
.turn
|
||||
.plugin_metrics_operation_for_command(&req.command, &cwd)
|
||||
})
|
||||
.flatten()
|
||||
.and_then(PluginMetricsSidecar::create);
|
||||
let metrics_sidecar = sidecar_for_command(
|
||||
ctx,
|
||||
&req.command,
|
||||
&req.cwd,
|
||||
req.turn_environment.environment.as_ref(),
|
||||
)
|
||||
.await;
|
||||
if let Some(sidecar) = metrics_sidecar.as_ref() {
|
||||
sidecar.install_output_env(&mut env);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user