Skip to content

fix(computer): end a step Codex declined as declined, not succeeded - #526

Open
yinwu01 wants to merge 1 commit into
simplexai-labs:mainfrom
yinwu01:fix/computer-codex-declined-outcome
Open

yinwu01 wants to merge 1 commit into
simplexai-labs:mainfrom
yinwu01:fix/computer-codex-declined-outcome

Conversation

@yinwu01

@yinwu01 yinwu01 commented Nov 22, 2026 •

Copy link
Copy Markdown

What and why

Codex ends a fileChange or commandExecution item with status declined
(CommandExecutionStatus,
PatchApplyStatus;
links are to Codex 0.166.0, the Daemon's minimum) when it refuses the step:

  • a patch whose approval was refused, for example by the permission review
    through the PermissionRequest hook, ends Declined
    (events.rs);
  • a command whose approval request the Daemon declines (answerServerCall does
    so while permission review is on) ends Declined with no exit code and no
    output
    (bespoke_event_handling.rs,
    completion item).

The Daemon passed the status on, but the Activity projection only treated
failed, error and cancelled as failures, so both finished their Activity as
succeeded: the Room showed a refused edit as done.

The Runner Gateway contract already has a declined outcome for
activity.finished, and Web's step details label it ("Declined"), but nothing
produced it. A declined step now ends its Activity with outcome declined. Its
output stays private; for these two shapes there is no reason text to show (the
patch output is the Daemon's own declined: N file changes). tool.returned is
unchanged.

Reply tracking

Before this change, a teamhub message send whose approval request was
declined also finished succeeded, so the Agent Service counted it as a
delivered message, and a Room Run whose only send was refused ended
succeeded with no reply in the Room. ReplyDelivery counts a declined
write as neither delivered nor failed. Since 7fb84e9 ("separate silent room
exits from reply_undelivered"), a Run whose writes were neither delivered nor
failed counts as replyNotSent while a Human who mentioned the Agent waits,
and main's reply-delivery.test.ts pins that for a declined write, so this PR
adds no Agent Service test. With this change such a send arrives as
declined. To see what the Agent Service then does, I made a local edit that
is not part of this PR: in main's run-loop case in which a Human who mentioned
the Agent waits and the only write ends canceled, I changed that outcome to
declined, and the Run still ends reply_not_sent.

An earlier version of this PR also changed ReplyDelivery to count a declined
write or read as failed (a write then ended the Run reply_undelivered).
7fb84e9 decided the other way and conflicted with it, so I rebased onto it and
dropped that part; this PR now changes only the Daemon's projection.

How it was verified

Not run against a live Codex; the item shapes come from the Codex sources linked
above.

Boundary

A command the PermissionRequest hook denies produces no item in this Codex: the
refusal happens before the command starts, so it gets no Activity, as before.
Web's compact activity view still treats a declined message-only group like a
successful one and hides it (isSuccessfulMessageOnlyGroup checks for failed),
and a Task row does not mark a declined teamhub task create as failed, as on
main; that is left to a Web change. No docs change: the Computer docs do not
list Activity outcomes, and the contract already has declined. No effect on
the user message → provider_ready path.

🤖 Generated with Claude Code

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve (0 findings)

Scope: base main, merge-base d4dd9255, 1 commit, 5 files reviewed. Helper skills: coderbook loaded; ponytail-review and karpathy-guidelines not loaded (their checklists were applied from the review skill's own list). Ran in a separate session.

Findings

None.

Verified as fine

  • declined really reaches the projection. Codex's commandExecution and fileChange completions pass item.Status through codexStatus, which only rewrites inProgress (apps/computer/local-daemon/internal/provider/native/codex_events.go:465-470). A declined command has no exit code, so the ExitCode != 0 → failed override does not apply (codex_events.go:408-410), and a declined patch emits Status: "declined" with output declined: N file changes (codex_events.go:422-424). Before this change, is_error covered only failed/error/cancelled (internal/provider/executor.go:768), so these steps finished as succeeded, as the PR says.
  • Precedence and content. declined is checked before is_error (event_projection.go:160-166), and it cannot also set is_error. Only outcome == "failed" gets the Error label (event_projection.go:174-178), so a declined step publishes no content. The receipt branch can still apply to a declined teamhub task create, but Codex reports no output for a declined command, so no content is published there either.
  • The outcome is valid on every downstream hop. The Runner Gateway contract enum includes declined (contracts/openapi/components/agent-runtime-state.yaml:1234). The Agent Service passes outcome through unchanged (apps/node-services/src/agent/runner-gateway/remote-codex-provider.ts:1266-1274, apps/node-services/src/agent/executor/runtime-status.ts:208-218), and RuntimeActivityOutcome already lists it (apps/node-services/src/agent/executor/provider.ts:213). TeamHub's validator accepts it (apps/teamhub/internal/agentruntimestate/status.go:443). No contract change or regeneration is needed.
  • Reply tracking. ReplyDelivery now counts a declined write as failed, which feeds replyUndelivered (apps/node-services/src/agent/executor/reply-delivery.ts:41-52), and a declined read as a failed read (:36-38, :65). This matches the updated rule in apps/node-services/src/agent/AGENTS.md:84-85, so the docs move with the code in the same PR.
  • Tests. TestDeclinedActivityEndsDeclined covers both Codex shapes (a patch with the summary output, a command with none). Without the fix it would get succeeded, so it fails on main. The new run-loop.test.ts case checks reply_undelivered and the logged counters for a declined write and a declined read.
  • PR description claims. They match the diff: tool.returned is unchanged, the contract is untouched, and the Web and task-row gaps are listed as out of scope. Nothing in the diff touches the user message → provider_ready path.
  • Conventions. No CJK in the added lines or the commit message. The comments explain why. There is no new env, config or cross-app import.

Process notes

  • The PR is one commit: no merge commits, no fixup commits. It is not behind main (HEAD..origin/main is empty).
  • gh pr checks reports no checks for this branch, so CI has to run before merge.

CI

gh pr checks reports no checks for this branch.

I ran locally: go test -count=1 -p 4 ./internal/provider/ -run 'TestDeclinedActivityEndsDeclined|TestEventProjection|TestFailedActivity' passed. Not run locally: the Node run-loop.test.ts (dependencies are not installed in this worktree). I reviewed its logic by reading the code instead.

Automated review by Claude Code


Automated review of 8cff7f6 by Claude Code.

Codex ends a fileChange or commandExecution item with status "declined"
when it refuses the step, for example a patch the permission review
denied, or a command whose approval request the Daemon declined. The
Daemon passed that status on, but the Activity projection only knew
failures, so a refused patch finished as "succeeded" in the Room, as if
the edit had been made. Before this change a declined teamhub message
send finished as succeeded too, so the Agent Service counted it as a
delivered message.

End a declined step's Activity with the contract's "declined" outcome,
which Web's step details already label. Its output stays private.

Verified: TestDeclinedActivityEndsDeclined fails without the fix and
passes with it; the other provider tests, make check-computer-go,
lint-go-daemon and the repository gate pass. Not run against a live
Codex.
@yinwu01
yinwu01 force-pushed the fix/computer-codex-declined-outcome branch from 8cff7f6 to e75c51c Compare November 24, 2026 14:50
@yinwu01

yinwu01 commented Nov 24, 2026

Copy link
Copy Markdown
Author

Rebased onto 7fb84e9 to resolve the conflict with it. That commit makes a Run whose message writes were neither delivered nor failed count as replyNotSent, and its new reply-delivery.test.ts pins that for a declined write. My ReplyDelivery change counted a declined write as failed, which makes that test fail on 7fb84e9 (I ran it), so I dropped the change along with the AGENTS.md sentence and the run-loop test.

What's left is the Daemon side: a step Codex declined now ends declined instead of succeeded. With main's reply tracking, a Room Run whose only send was declined while a Human waits then ends reply_not_sent; I checked that with main's run-loop case switched to a declined outcome. Updated the description to match; not run against a live Codex.

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve with nits (1 P2)

Scope: follow-up on 8cff7f6. Base main, merge-base 7fb84e97, 1 commit, 2 files reviewed. Loaded coderbook; ponytail-review and karpathy-guidelines were not loaded, and their checks were applied from the review checklist. Ran in a separate session.

The PR was rebased onto 7fb84e97 since the previous review. git range-diff shows the ReplyDelivery change, its run-loop test and the apps/node-services/src/agent/AGENTS.md edit are gone. The Daemon projection change and its test did not change.

Previous findings

  • The previous review had no findings.

Findings

P2

  • The PR description claims a test change the diff doesn't contain. See apps/node-services/tests/agent/executor/run-loop.test.ts:516. The body says: "I took main's run-loop case in which a Human who mentioned the Agent waits and the only write ends canceled, and changed that outcome to declined: the Run still ends reply_not_sent." The diff touches only event_projection.go and events_regression_test.go, and line 516 still uses messageWrite("send-1", "canceled"). The behaviour itself is still covered at the unit level by main's reply-delivery.test.ts:93 (it.each([undefined, "canceled", "declined"])), so no behaviour is left untested. Fix: add the run-loop change, or remove the sentence from the description.

Verified as fine

  • Codex passes declined through unchanged. codexStatus maps only inProgress (internal/provider/native/codex_events.go:426-431). commandExecution keeps declined unless the exit code is non-zero (codex_events.go:369-377). A declined command has no exit code. fileChange emits Status: status with Output: "declined: N file changes" (codex_events.go:383-385), which matches the test fixture.
  • declined takes precedence over is_error. is_error is true only for failed, error and cancelled (internal/provider/executor.go:769), so the two cases in the new switch (event_projection.go:160-167) can't both match.
  • Output stays private. Content is attached only for outcome == "failed" or a Task-creation receipt (event_projection.go:172-182). A declined patch never publishes its summary. A declined teamhub task create command has no aggregated output, so it publishes nothing either.
  • The contract already allows declined. AgentRuntimeActivityOutcome lists it (contracts/openapi/components/agent-runtime-state.yaml:1285), and the Agent Service's RunActivityOutcome includes it (apps/node-services/src/agent/executor/provider.ts:225). No contract regeneration is needed.
  • The reply-tracking effect matches the description. ReplyDelivery counts only succeeded and failed (apps/node-services/src/agent/executor/reply-delivery.ts:35-38). A declined send therefore no longer counts as delivered, and it is treated as neither delivered nor failed, as the body says.
  • Language check: no CJK in the added lines or in the commit message.

Process notes

  • The branch is 9 commits behind main. main requires up-to-date branches, so it needs a rebase.
  • There are no merge commits or fixup commits.

CI

  • gh pr checks reports no checks on this branch, so CI has not run on this head and needs to before merge.
  • I ran this locally: go test -count=1 -p 4 -run 'TestDeclinedActivityEndsDeclined|TestEventProjection|TestFailedActivity' ./internal/provider/ passes.
  • No -race run was needed, since the change has no concurrency.

Automated review by Claude Code


Automated review of e75c51c by Claude Code.

@yinwu01

yinwu01 commented Nov 24, 2026

Copy link
Copy Markdown
Author

Re the bot's P2: that run-loop check was a local edit against 7fb84e9, not part of this diff. I reworded the description to say so. I didn't add that run-loop change as a test, since main's reply-delivery.test.ts already pins a declined write as replyNotSent.

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve (0 findings)

Scope: follow-up on e75c51c (the head is unchanged since the previous review). Base main, merge base 7fb84e97; 1 commit, 2 files reviewed. Helper skills: coderbook loaded; ponytail-review and karpathy-guidelines were not loaded, and their checklists were applied from the review instructions instead. Ran in a separate session.

Previous findings

  • Resolved: the PR body claimed a run-loop test change that is not in the diff (apps/node-services/tests/agent/executor/run-loop.test.ts:516). The body now says it was "a local edit that is not part of this PR", made only to check what the Agent Service does. So the description no longer claims the change, and the code needs no update.

Findings

None.

Verified as fine

  • Status reaches the projection. For fileChange and commandExecution, codexStatus passes declined through unchanged (native/codex_events.go:426-431). A declined command has no exit code, so the ExitCode != 0 → failed override does not apply (codex_events.go:370-372).
  • Ordering. The declined check runs before the is_error check (event_projection.go:160-166). In executor.go:769, is_error is computed only from failed/error/cancelled, so the two cases never overlap.
  • Output stays private. A declined step gets no content: the label is set only for failed, or when there is a task receipt (event_projection.go:171-176). The test checks content == nil for both shapes.
  • Contract. declined is already in the outcome enum (contracts/openapi/components/agent-runtime-state.yaml:1285) and in the TypeScript provider type (apps/node-services/src/agent/executor/provider.ts:225). No regeneration is needed.
  • Agent Service. ReplyDelivery counts only succeeded as delivered and failed as failed (reply-delivery.ts:30-40). A declined write is therefore neither, which matches the replyNotSent behaviour the PR body describes.
  • Size of the fix. The change is minimal and targets the root cause, in the one place the outcome is decided. The new test fails without the fix (per the body), and the shape of its assertions matches the projection code.
  • Conventions. No CJK in the added lines or the commit message. The new comment explains why. No merge commits.

Process notes

  • The branch is 27 commits behind main, and main requires up-to-date branches, so it needs a rebase.
  • gh pr checks reports no checks on this branch, so CI has to be triggered.

CI

No checks were reported for the PR branch. I ran go test -count=1 -p 4 -run 'TestDeclinedActivityEndsDeclined|TestEventProjection|TestFailedActivity' ./internal/provider/ myself, and it passed. The change touches no concurrency, so I did not run it with -race.

Automated review by Claude Code


Automated review of e75c51c by Claude Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant