mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
Record sandbox backends in command execution analytics (#47568)
## Why Command execution analytics lack the observed sandbox backend. Older execution servers may omit this information, so an unknown backend must remain distinguishable from an explicitly unsandboxed process. ## What changed - Carry optional `sandbox_type` metadata through command execution items and emit its metric tag as `sandbox_backend` in analytics. - Propagate the observed backend through unified execution completion and failure events, including asynchronous exits. - Preserve missing backend information as `None` and mark executed user shell commands as `Some(SandboxType::None)`. - Exclude the metadata from serialized command items and generated schemas and TypeScript types. ## Testing Extend tests for missing and explicit executor backends, backend propagation on failed execution, and analytics payloads, including platform-specific backend tags in app-server integration coverage. GitOrigin-RevId: 178fe46824a6194910802ec02168ed40ee0b2019
This commit is contained in:
@@ -98,6 +98,7 @@ pub fn build_command_execution_begin_item(payload: &ExecCommandBeginEvent) -> Th
|
||||
CommandExecutionPresentation::from_raw(&payload.command, &payload.parsed_cmd, &payload.cwd);
|
||||
ThreadItem::CommandExecution {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: payload.call_id.clone(),
|
||||
plugin_id: payload.plugin_id.clone(),
|
||||
script_path: payload.script_path.clone(),
|
||||
@@ -125,6 +126,7 @@ pub fn build_command_execution_end_item(payload: &ExecCommandEndEvent) -> Thread
|
||||
|
||||
ThreadItem::CommandExecution {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: payload.call_id.clone(),
|
||||
plugin_id: payload.plugin_id.clone(),
|
||||
script_path: payload.script_path.clone(),
|
||||
@@ -202,6 +204,7 @@ pub fn build_item_from_guardian_event(
|
||||
Some(ThreadItem::CommandExecution {
|
||||
id: id.clone(),
|
||||
model_context: assessment.model_context.clone(),
|
||||
sandbox_type: None,
|
||||
plugin_id: assessment.plugin_id.clone(),
|
||||
script_path: assessment.script_path.clone(),
|
||||
command,
|
||||
@@ -241,6 +244,7 @@ pub fn build_item_from_guardian_event(
|
||||
Some(ThreadItem::CommandExecution {
|
||||
id: id.clone(),
|
||||
model_context: assessment.model_context.clone(),
|
||||
sandbox_type: None,
|
||||
plugin_id: assessment.plugin_id.clone(),
|
||||
script_path: assessment.script_path.clone(),
|
||||
command,
|
||||
|
||||
@@ -2391,6 +2391,7 @@ mod tests {
|
||||
}];
|
||||
let command_item = CoreTurnItem::CommandExecution(CoreCommandExecutionItem {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: "exec-1".to_string(),
|
||||
plugin_id: Some("sample@openai-curated".to_string()),
|
||||
script_path: Some("scripts/run.py".to_string()),
|
||||
@@ -2477,6 +2478,7 @@ mod tests {
|
||||
build_turns_from_rollout_items(&items[..2])[0].items,
|
||||
vec![ThreadItem::CommandExecution {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: "exec-1".to_string(),
|
||||
plugin_id: Some("sample@openai-curated".to_string()),
|
||||
script_path: Some("scripts/run.py".to_string()),
|
||||
@@ -2503,6 +2505,7 @@ mod tests {
|
||||
turns[0].items,
|
||||
vec![ThreadItem::CommandExecution {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: "exec-1".to_string(),
|
||||
plugin_id: Some("sample@openai-curated".to_string()),
|
||||
script_path: Some("scripts/run.py".to_string()),
|
||||
@@ -3191,6 +3194,7 @@ mod tests {
|
||||
turns[0].items[2],
|
||||
ThreadItem::CommandExecution {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: "exec-1".into(),
|
||||
plugin_id: None,
|
||||
script_path: None,
|
||||
@@ -3465,6 +3469,7 @@ mod tests {
|
||||
turns[0].items[1],
|
||||
ThreadItem::CommandExecution {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: "exec-declined".into(),
|
||||
plugin_id: None,
|
||||
script_path: None,
|
||||
@@ -3575,6 +3580,7 @@ mod tests {
|
||||
turns[0].items[1],
|
||||
ThreadItem::CommandExecution {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: "guardian-exec".into(),
|
||||
plugin_id: Some("sample@openai-curated".into()),
|
||||
script_path: Some("scripts/run.py".into()),
|
||||
@@ -3649,6 +3655,7 @@ mod tests {
|
||||
turns[0].items[1],
|
||||
ThreadItem::CommandExecution {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: "guardian-execve".into(),
|
||||
plugin_id: Some("sample@openai-curated".into()),
|
||||
script_path: Some("scripts/run.py".into()),
|
||||
@@ -3852,6 +3859,7 @@ mod tests {
|
||||
turns[0].items[1],
|
||||
ThreadItem::CommandExecution {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: "exec-late".into(),
|
||||
plugin_id: None,
|
||||
script_path: None,
|
||||
|
||||
@@ -289,6 +289,10 @@ pub enum ThreadItem {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase")]
|
||||
CommandExecution {
|
||||
#[serde(skip)]
|
||||
#[schemars(skip)]
|
||||
#[ts(skip)]
|
||||
sandbox_type: Option<codex_protocol::sandbox::SandboxType>,
|
||||
#[serde(skip)]
|
||||
#[schemars(skip)]
|
||||
#[ts(skip)]
|
||||
@@ -919,6 +923,7 @@ impl From<CoreTurnItem> for ThreadItem {
|
||||
ThreadItem::CommandExecution {
|
||||
id: command.id,
|
||||
model_context: command.model_context,
|
||||
sandbox_type: command.sandbox_type,
|
||||
plugin_id: command.plugin_id,
|
||||
script_path: command.script_path,
|
||||
command: presentation.command,
|
||||
|
||||
@@ -3272,6 +3272,7 @@ fn core_turn_item_into_thread_item_converts_supported_variants() {
|
||||
|
||||
let command_item = TurnItem::CommandExecution(CommandExecutionItem {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: "exec-1".to_string(),
|
||||
plugin_id: Some("sample@openai-curated".to_string()),
|
||||
script_path: Some("scripts/run.py".to_string()),
|
||||
@@ -3305,6 +3306,7 @@ fn core_turn_item_into_thread_item_converts_supported_variants() {
|
||||
ThreadItem::from(command_item),
|
||||
ThreadItem::CommandExecution {
|
||||
model_context: None,
|
||||
sandbox_type: None,
|
||||
id: "exec-1".to_string(),
|
||||
plugin_id: Some("sample@openai-curated".to_string()),
|
||||
script_path: Some("scripts/run.py".to_string()),
|
||||
|
||||
Reference in New Issue
Block a user