Skip to content

fix(codex): honor run budgets and prevent false terminal success - #98940

Open
danhayman wants to merge 4 commits into
NousResearch:mainfrom
danhayman:fix/codex-app-server-turn-deadline
Open

fix(codex): honor run budgets and prevent false terminal success#98940
danhayman wants to merge 4 commits into
NousResearch:mainfrom
danhayman:fix/codex-app-server-turn-deadline

Conversation

@danhayman

Copy link
Copy Markdown

Summary

Fix Codex app-server turns being forcibly terminalized after a hardcoded 600 seconds and incorrectly returning interim assistant/progress text as successful final output.

The change:

  • propagates the caller's monotonic run budget through the entire native app-server turn, including startup and turn/start;
  • defines no-budget behavior without an arbitrary whole-turn cutoff;
  • accepts missing-turn/completed compatibility only for protocol-grounded final_answer items, snapshotting canonical text so later commentary cannot replace it;
  • returns explicit partial/error state and retires/interupts on real deadlines rather than promoting arbitrary text;
  • preserves post-tool silence, explicit interrupt, process-death, provider-timeout, and session-retirement semantics;
  • makes approval waits deadline/interrupt/process-death aware;
  • prevents terminal pre-drain from authorizing a queued request;
  • makes the real CLI approval modal cancellation-wakeable and guarantees cooperative worker/modal cleanup before return;
  • keeps unknown non-cooperative third-party callbacks bounded.

Reproduction

Multiple native Codex app-server sessions launched with --run-budget 10800 or 14400 ended at exactly 600 seconds with:

codex app-server turn reached deadline after a completed assistant message but before turn/completed; accepting the assistant text as the terminal response

The accepted text was an interim progress message and the CLI exited code 0. The defect also reproduced while implementing this fix.

Related upstream context:

This PR addresses the combined deadline, event-classification, and approval-lifecycle bug class.

Verification

Final remediation and independent review evidence includes:

  • 1,886 expanded approval/CLI/runtime tests passed; 8 Windows-only skipped.
  • 460 transport/runtime tests passed during remediation.
  • Independent review: 441/441 transport/runtime and 118/118 changed base-path tests passed.
  • Terminal completed/interrupted/failed pre-drain cases: 5/5 passed.
  • Real CLI process-death, interrupt, deadline, active-approval, late-response, lock-contention, and callback-reentrancy reproductions passed.
  • Non-cooperative callback remained bounded at approximately 0.300 seconds.
  • Ruff, py_compile, and git diff --check passed.
  • Exact candidate independently reviewed and approved: 44c7ff3aafe37a28495ddf6d5f7afd57cda51688.

A broader unrelated test can be environment-sensitive when /tmp resolves inside a Git workspace; no failure implicated this diff.

Deployment

No live gateway was restarted or modified while developing or reviewing this change.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard provider/openai OpenAI / Codex Responses API P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/openai OpenAI / Codex Responses API sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants