mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
## 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
118 lines
4.1 KiB
Rust
118 lines
4.1 KiB
Rust
use super::*;
|
|
use codex_app_server_protocol::CommandExecutionSource;
|
|
use codex_app_server_protocol::CommandExecutionStatus;
|
|
use codex_app_server_protocol::ItemCompletedNotification;
|
|
use codex_utils_absolute_path::AbsolutePathBuf;
|
|
|
|
#[test]
|
|
fn agent_status_uses_bounded_buffered_activity() {
|
|
let mut store = ThreadEventStore::new(/*capacity*/ 8);
|
|
store.push_notification(ServerNotification::ItemCompleted(
|
|
ItemCompletedNotification {
|
|
item: ThreadItem::CommandExecution {
|
|
model_context: None,
|
|
sandbox_type: None,
|
|
id: "command-1".to_string(),
|
|
command: "cargo test -p codex-tui".to_string(),
|
|
cwd: AbsolutePathBuf::try_from("/workspace")
|
|
.expect("absolute path")
|
|
.into(),
|
|
process_id: None,
|
|
plugin_id: None,
|
|
script_path: None,
|
|
source: CommandExecutionSource::Agent,
|
|
status: CommandExecutionStatus::Completed,
|
|
command_actions: Vec::new(),
|
|
aggregated_output: Some("unbounded output\n".repeat(10_000)),
|
|
exit_code: Some(0),
|
|
duration_ms: Some(42),
|
|
},
|
|
thread_id: "thread-child".to_string(),
|
|
turn_id: "turn-1".to_string(),
|
|
completed_at_ms: 1,
|
|
},
|
|
));
|
|
store.push_notification(ServerNotification::ItemCompleted(
|
|
ItemCompletedNotification {
|
|
item: ThreadItem::AgentMessage {
|
|
id: "message-1".to_string(),
|
|
text: "Finished checking the focused TUI tests.".to_string(),
|
|
phase: None,
|
|
memory_citation: None,
|
|
delivery: None,
|
|
questions: None,
|
|
},
|
|
thread_id: "thread-child".to_string(),
|
|
turn_id: "turn-1".to_string(),
|
|
completed_at_ms: 2,
|
|
},
|
|
));
|
|
|
|
let preview = AgentStatusThreadPreview::from_store("/root/reviewer".to_string(), &store);
|
|
let cell = AgentStatusHistoryCell::new(vec![preview]);
|
|
let rendered = cell
|
|
.display_lines(/*width*/ 80)
|
|
.iter()
|
|
.map(ToString::to_string)
|
|
.collect::<Vec<_>>()
|
|
.join("\n");
|
|
|
|
insta::assert_snapshot!(rendered, @r###"
|
|
/subagents
|
|
Sub-agents running
|
|
|
|
• `/root/reviewer`
|
|
$ cargo test -p codex-tui
|
|
Finished checking the focused TUI tests.
|
|
"###);
|
|
assert!(!rendered.contains("unbounded output"));
|
|
}
|
|
|
|
#[test]
|
|
fn agent_status_uses_reasoning_summaries_only() {
|
|
let mut store = ThreadEventStore::new(/*capacity*/ 8);
|
|
store.push_notification(ServerNotification::ItemCompleted(
|
|
ItemCompletedNotification {
|
|
item: ThreadItem::Reasoning {
|
|
id: "reasoning-with-summary".to_string(),
|
|
summary: vec!["safe summary".to_string()],
|
|
content: vec!["hidden raw reasoning".to_string()],
|
|
},
|
|
thread_id: "thread-child".to_string(),
|
|
turn_id: "turn-1".to_string(),
|
|
completed_at_ms: 1,
|
|
},
|
|
));
|
|
store.push_notification(ServerNotification::ItemCompleted(
|
|
ItemCompletedNotification {
|
|
item: ThreadItem::Reasoning {
|
|
id: "reasoning-without-summary".to_string(),
|
|
summary: Vec::new(),
|
|
content: vec!["raw-only reasoning".to_string()],
|
|
},
|
|
thread_id: "thread-child".to_string(),
|
|
turn_id: "turn-1".to_string(),
|
|
completed_at_ms: 2,
|
|
},
|
|
));
|
|
|
|
let preview = AgentStatusThreadPreview::from_store("/root/reviewer".to_string(), &store);
|
|
let cell = AgentStatusHistoryCell::new(vec![preview]);
|
|
let rendered = cell
|
|
.display_lines(/*width*/ 80)
|
|
.iter()
|
|
.map(ToString::to_string)
|
|
.collect::<Vec<_>>()
|
|
.join("\n");
|
|
|
|
insta::assert_snapshot!(rendered, @r###"
|
|
/subagents
|
|
Sub-agents running
|
|
|
|
• `/root/reviewer`
|
|
safe summary
|
|
"###);
|
|
assert!(!rendered.contains("hidden raw reasoning"));
|
|
assert!(!rendered.contains("raw-only reasoning"));
|
|
}
|