Skip to content

fix(codex): preserve terminal outcome ordering#93287

Merged
steipete merged 1 commit into
mainfrom
fix/codex-terminal-outcome-ordering
Jun 15, 2026
Merged

fix(codex): preserve terminal outcome ordering#93287
steipete merged 1 commit into
mainfrom
fix/codex-terminal-outcome-ordering

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • derive Codex tool outcome order from raw model call order, then reuse it across native and dynamic lifecycle events
  • prevent delayed native completions, earlier dynamic failures, and cancellation-ignoring timed-out tools from replacing the actual last tool presentation
  • ignore stale prior-turn snapshot items and cover the ID-less native web-search path

Follow-up to #93228 and its ordering review findings:

Verification

  • pnpm test extensions/codex/src/app-server/event-projector.test.ts extensions/codex/src/app-server/run-attempt.dynamic-tools.test.ts extensions/codex/src/app-server/dynamic-tool-build.test.ts extensions/codex/src/app-server/dynamic-tool-execution.test.ts src/agents/agent-tools.before-tool-call.integration.e2e.test.ts
  • Crabbox Azure Linux run run_ec1338fa8af3: pnpm check:changed, pnpm build, and the same focused 168-test set
  • fresh autoreview: no actionable findings

Real behavior proof

Behavior addressed: Codex incomplete-turn fallback now selects the last model-ordered tool outcome instead of notification or completion order.
Real environment tested: Azure Linux Standard_D32ads_v6 through Crabbox.
Exact steps or command run after this patch: changed checks, full production build, then focused core/Codex E2E tests.
Evidence after fix: Crabbox run run_ec1338fa8af3 exited 0; 22 core E2E and 146 Codex extension tests passed.
Observed result after fix: delayed native command/web-search completions and earlier dynamic failures no longer clear a later dynamic summary; late success after timeout is suppressed.
What was not tested: live provider traffic against a production Codex account.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for e3dc5bb5d34472af93b8da72ce1fd6757d30561f:

  • Local focused proof: pnpm test extensions/codex/src/app-server/event-projector.test.ts extensions/codex/src/app-server/run-attempt.dynamic-tools.test.ts extensions/codex/src/app-server/dynamic-tool-build.test.ts extensions/codex/src/app-server/dynamic-tool-execution.test.ts src/agents/agent-tools.before-tool-call.integration.e2e.test.ts (168 tests passed after rebase).
  • Remote broad proof: Crabbox Azure Linux run run_ec1338fa8af3 on Standard_D32ads_v6 ran pnpm check:changed, pnpm build, and the same focused test command; exit 0.
  • Fresh autoreview: clean, no accepted/actionable findings.
  • Real behavior covered: model-order inversion across raw calls and delayed native command/web-search lifecycle, stale turn snapshots, late earlier failures, and timeout-ignoring late success.
  • Known proof gap: no live production Codex account traffic.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: codex size: L maintainer Maintainer-authored PR labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(codex): preserve terminal outcome ordering This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit a09f6b1 into main Jun 15, 2026
191 of 195 checks passed
@steipete
steipete deleted the fix/codex-terminal-outcome-ordering branch June 15, 2026 12:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3dc5bb5d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +686 to +690
if (
observation.toolCallOrdinal !== undefined &&
suppressedDynamicToolOutcomeOrdinals.has(observation.toolCallOrdinal)
) {
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Preserve late timeout outcomes for loop guards

When a Codex dynamic tool times out/aborts but the underlying tool ignores cancellation and later completes, this ordinal-wide suppression drops every subsequent onToolOutcome, including the normal non-presentationOnly observation emitted by the before-tool-call wrapper. The runner's observer in src/agents/embedded-agent-runner/run.ts:1352 only feeds postCompactionGuard.observe() for non-presentation observations, so these late real outcomes no longer participate in the post-compaction loop guard; only the terminal presentation needed to be suppressed/cleared. Consider forwarding non-presentation observations with terminalPresentation stripped instead of returning here.

Useful? React with 👍 / 👎.

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

Labels

agents Agent runtime and tooling extensions: codex maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant