mirror of
https://github.com/openai/codex.git
synced 2026-11-18 15:01:48 +00:00
feat(core): emit canonical command execution items (#31297)
This PR depends on [#31296](https://github.com/openai/codex/pull/31296) for the canonical-to-legacy event mappings. ## Description This PR makes command execution emit canonical `TurnItem::CommandExecution` lifecycle from both the shell tool path and user `/shell` commands. App-server v2 consumes the canonical command items directly and ignores the mapped `ExecCommandBegin` / `ExecCommandEnd` compatibility events, so clients still receive one command item lifecycle. `UnifiedExecInteraction` stays on the legacy path because `TerminalInteraction` is still the v2 surface for stdin and poll events. Emitting a command item there would render the same wait twice. ## Why This is the first live producer migration after the compatibility mappings in #31296. Keeping command execution separate makes the unified exec exception reviewable without mixing in dynamic tools or multi-agent behavior. ## What changed - Emit canonical command execution items from shell tool events and user shell commands. - Preserve the existing unified exec interaction carveout. - Move app-server command deduplication and completion bookkeeping onto canonical item events. - Update unified exec coverage to assert the completed command item.
This commit is contained in:
1 parent
d7ab20ce62
commit
cca16a1087
5 files changed
+181
-136
No files matched your search
@@ -573,9 +573,8 @@ impl UnifiedExecProcessManager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Short‑lived command: emit ExecCommandEnd immediately using the
|
||||
// same helper as the background watcher, so all end events share
|
||||
// one implementation.
|
||||
// Short-lived command: emit the completed command item immediately
|
||||
// using the same helper as the background watcher.
|
||||
let finish_result = finish_deferred_network_approval_after_process_exit_for_session(
|
||||
Some(&context.session),
|
||||
deferred_network_approval.take(),
|
||||
|
||||
@@ -315,21 +315,24 @@ async fn failed_initial_end_for_unstored_process_uses_fallback_output() {
|
||||
|
||||
let event = tokio::time::timeout(Duration::from_secs(1), rx_event.recv())
|
||||
.await
|
||||
.expect("timed out waiting for failed exec end event")
|
||||
.expect("timed out waiting for failed command execution item")
|
||||
.expect("event channel closed");
|
||||
let codex_protocol::protocol::EventMsg::ExecCommandEnd(end_event) = event.msg else {
|
||||
panic!("expected ExecCommandEnd event");
|
||||
let codex_protocol::protocol::EventMsg::ItemCompleted(completed_event) = event.msg else {
|
||||
panic!("expected ItemCompleted event");
|
||||
};
|
||||
assert_eq!(end_event.call_id, "call-unified-denied");
|
||||
let codex_protocol::items::TurnItem::CommandExecution(item) = completed_event.item else {
|
||||
panic!("expected CommandExecution item");
|
||||
};
|
||||
assert_eq!(item.id, "call-unified-denied");
|
||||
assert_eq!(
|
||||
end_event.status,
|
||||
codex_protocol::protocol::ExecCommandStatus::Failed
|
||||
item.status,
|
||||
codex_protocol::items::CommandExecutionStatus::Failed
|
||||
);
|
||||
assert_eq!(end_event.exit_code, -1);
|
||||
assert_eq!(end_event.process_id.as_deref(), Some("123"));
|
||||
assert_eq!(item.exit_code, Some(-1));
|
||||
assert_eq!(item.process_id.as_deref(), Some("123"));
|
||||
assert_eq!(
|
||||
end_event.aggregated_output,
|
||||
"PRE_DENIAL_MARKER\nNetwork access denied"
|
||||
item.aggregated_output.as_deref(),
|
||||
Some("PRE_DENIAL_MARKER\nNetwork access denied")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user