Skip to content

fix(codex): prevent bounded turns from timing out on slow model lookup - #159209

Closed
bdjben wants to merge 1 commit into
openclaw:mainfrom
bdjben:codex/codex-model-list-deadline
Closed

bdjben wants to merge 1 commit into
openclaw:mainfrom
bdjben:codex/codex-model-list-deadline

Conversation

@bdjben

@bdjben bdjben commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a bounded Codex side turn can fail before it starts when a live model/list reply takes more than five seconds, even when the configured app-server request budget and remaining turn budget are longer.

User Impact

Side questions and settled-turn finalizers that need a live model list can proceed when the lookup completes within the configured request budget. A stalled lookup may now wait longer than five seconds, but it remains bounded by both appServer.requestTimeoutMs and the remaining turn budget. No configuration or data migration is required.

Why This Change Was Made

The bounded-turn model lookup had a fixed five-second ceiling. It now uses the smaller of the remaining turn budget and the configured app-server request timeout, matching the caller's intended deadlines. The documentation describes that behavior.

Evidence

  • A direct request to a real Codex app-server was observed to take 5.006 seconds for model/list after client acquisition, exceeding the previous five-second ceiling. This observation establishes that the lookup can take longer than the old cap; it is not an end-to-end bounded-turn success claim.
  • Regression using a real CodexAppServerClient transport with controlled response timing: on the unchanged base, a six-second catalog response failed with model/list timed out despite an eight-second configured request budget. With this change, the six-second response succeeds and starts the turn, while a nine-second response still times out before turn/start.
  • pnpm test extensions/codex/src/app-server/bounded-turn.test.ts --maxWorkers=1: 44/44 passed, 20.27 seconds local wall time. The adjacent bounded-turn clock suite also passed: 47/47 tests across the two files in 21.91 seconds.
  • Formatting and git diff --check passed. Local scoped autoreview found no actionable findings.

The full changed-lane check did not finish: its extension-test typecheck was interrupted during heavy host contention. CI has not been awaited. A separate live foreground-agent path still showed app-server request timeouts after an integration build containing this change, so this PR does not claim to fix those broader fresh-session failures.

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: S labels Sep 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

The PR makes bounded Codex model lookup honor the configured request timeout while preserving the turn deadline.

Example: A model catalog responds after six seconds with an eight-second request timeout and a twenty-second turn budget.

  • Before: Model lookup fails after five seconds, before the turn starts.
  • After: The catalog response is accepted and the turn starts; a nine-second response still exceeds the request timeout.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch and meaningful regression coverage support correctness, but the changed behavior's evidence remains confined to a mocked transport.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A bounded Codex inference request can fail before producing an answer because model lookup is cut short despite available request and execution budgets.
Reason: The patch repairs the stated lookup failure in the shared owner without claiming to resolve separate foreground startup failures.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this PR open: current main retains the premature five-second lookup deadline, and this focused repair has no identified correctness defect.

Priority: P2
Reviewed head: b34577f2f1930ed069e57975e92bd16a7e2e171b

Before merge

  • Add real behavior proof - The changed bounded-turn owner is exercised by a real client over mocked process streams and fake timers. The reported live lookup exceeding five seconds establishes the trigger, but does not exercise successful bounded inference after the fix. Supply logs, live output, or a terminal recording of delayed success and over-budget rejection through a real transport, with IPs, API keys, phone numbers, and non-public endpoints redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Complete next step - Mark this PR ready for review when the contributor intends it to proceed.

Findings

None.

Tests

  • Missing end-to-end proof: Provide a redacted trace through a shipped bounded-turn entry point or production owner with a real transport, showing delayed lookup success within the configured budget and timeout before turn/start beyond it.
Agent review details

How this fits together

The Codex plugin's bounded-turn owner receives isolated inference requests, obtains a native model catalog, selects a model, and starts an ephemeral thread that returns text or an error.

flowchart LR
  A[Bounded inference request] --> B[Turn deadline]
  A --> C[Configured request timeout]
  B --> D[Model lookup]
  C --> D
  D --> E[Codex catalog]
  E --> F[Ephemeral thread]
  F --> G[Text or error]
Loading

Technical review

Best possible solution:

Keep model lookup in the existing bounded-turn owner and use its configured request limit together with the elapsed turn deadline.

Do we have a high-confidence way to reproduce the issue?

Source establishes the failure path: current main rejects a six-second model/list response under its fixed five-second cap despite a longer configured request and turn budget; the contributor reports a matching base failure, but this read-only review ran no reproduction.

Is this the best way to solve the issue?

This is a narrow owner-level repair that reuses an existing setting, retains cancellation and authority checks, and avoids adding another timeout policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 95dcdf93588b.

Provenance checked

  • Bounded-turn model lookup deadline changes intended behavior with a stated reason (1e0062b: The hosted-search change introduced a shared isolated bounded-turn lifecycle with a five-second lookup ceiling; its merged PR explains isolation but gives no separate rationale for that ceiling.)
  • Live authority and elapsed turn deadline keeps the original intent (refactor: share background capacity across dreaming and skill reviews #136938: Shared background execution carries live authority through provider admission; the later monotonic-deadline repair preserves the elapsed budget across startup.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Verified introduced change: The pinned introduction replaces the fixed model/list ceiling with the existing configured request timeout and adds delayed-response regression cases and documentation. (extensions/codex/src/app-server/bounded-turn.ts:586, b34577f2f193)
  • Current-main necessity: Fetched main still uses Math.min(params.timeoutMs, 5_000) for this model/list request. (extensions/codex/src/app-server/bounded-turn.ts:562, 95dcdf93588b)
  • Existing deadline and authority boundaries: The turn installs a remaining-budget abort independently of the request timeout, and preserves signal and assertCurrent propagation into model lookup and subsequent requests. (extensions/codex/src/app-server/bounded-turn.ts:219, b34577f2f193)
  • Regression harness boundary: The added cases exercise the production bounded-turn owner and client, but createClientHarness supplies PassThrough streams and a synthetic process through fromTransportForTests; response timing uses fake timers. (extensions/codex/src/app-server/bounded-turn.test.ts:857, b34577f2f193)
  • Complete supplied proof and discussion: The full REST body and comments contain a reported slow live lookup and controlled-harness outcomes, but no changed-path real-transport trace or successful shipped-entry-point run. The previous review rated that harness sufficient; this review applies the explicit distinction between real transport and mocked transport. Captured sourceRevision: 32afc56b7794fbb7d95249dee58c4450fba4b7c5082862787400ab7ec0c83d33. (b34577f2f193)
  • Personally inspected authoritative dependency: OpenClaw directly consumes Codex's model/list protocol, making this dependency contract applicable. The sibling checkout and cache origin identify openai/codex; supported_models awaits OnlineIfUncached, whose manager fetches online when no usable cache exists. (codex-rs/app-server/src/models.rs:19, be2951ea34f0)

Likely related people:

  • Jason (Json): Raw commit 1e0062b adds extensions/codex/src/app-server/bounded-turn.ts:266 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1e0062b44a51; files: extensions/codex/src/app-server/bounded-turn.ts)

PR surface

Source +2, Tests +66, Docs +3. Total +71 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 3 1 +2
Tests 1 66 0 +66
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 72 1 +71

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The unintended catalog deadline can abort bounded Codex inference before it starts, with limited scope and a focused repair.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach the real-transport delayed-response evidence described in the proof assessment.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-26T22:05:30.689Z sha b34577f :: needs maintainer review before merge. :: none

Reviewed October 11, 2026, 1:29 PM ET / 17:29 UTC (Revision 2).

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
@barnacle-openclaw

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@barnacle-openclaw barnacle-openclaw Bot added the stale Marked as stale due to inactivity label Oct 15, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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

Labels

docs Improvements or additions to documentation extensions: codex P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant