mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Persist command completions when approval is declined or fails (#64341)
## Why The app server completed command items for rejected approval responses directly in the live stream. That bypassed core's history recording, so clients could see a completed command live and lose it when reloading the turn. ## What changed Keep top-level command items with their pending approvals in core. Record and emit the command completion before unblocking the turn. Declines and cancellations produce a `declined` item, while invalid responses and approval request failures produce a `failed` item. ## Testing App-server integration tests cover cancellation, decline, and malformed responses. They check that `item/completed` precedes `turn/completed` and that paginated history returns the same command item after restart. GitOrigin-RevId: d3d95272c8a6af2fa65fa980f312260313cc5e32
This commit is contained in:
@@ -356,6 +356,13 @@ pub struct ExecApprovalRequestEvent {
|
||||
}
|
||||
|
||||
impl ExecApprovalRequestEvent {
|
||||
/// Only a top-level command prompt opens a new execution item.
|
||||
pub fn starts_command(&self) -> bool {
|
||||
self.kind == ExecApprovalKind::Command
|
||||
&& self.approval_id.is_none()
|
||||
&& self.network_approval_context.is_none()
|
||||
}
|
||||
|
||||
pub fn effective_approval_id(&self) -> String {
|
||||
self.approval_id
|
||||
.clone()
|
||||
|
||||
@@ -1780,11 +1780,7 @@ impl EventMsg {
|
||||
/// Stdin and network reviews have their own prompts for an existing operation.
|
||||
pub fn command_approval_start(&self) -> Option<(&str, i64)> {
|
||||
match self {
|
||||
Self::ExecApprovalRequest(request)
|
||||
if request.kind == crate::approvals::ExecApprovalKind::Command
|
||||
&& request.approval_id.is_none()
|
||||
&& request.network_approval_context.is_none() =>
|
||||
{
|
||||
Self::ExecApprovalRequest(request) if request.starts_command() => {
|
||||
Some((&request.call_id, request.started_at_ms))
|
||||
}
|
||||
Self::GuardianAssessment(assessment)
|
||||
|
||||
Reference in New Issue
Block a user