Skip to content

fix(codex): recovered dashboard turns fail before reaching the model - #176707

Merged
steipete merged 1 commit into
mainfrom
fix/codex-recovered-web-search-policy
Oct 19, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/codex-recovered-web-search-policy

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: after a Gateway restart, an interrupted Control UI session running on the Codex harness is "resumed" by restart recovery but its turn fails within seconds with Session capability metadata requires worker preparation, and the session stays stranded.

User Impact

User impact: restart recovery now actually resumes interrupted Control UI (dashboard) sessions on the Codex harness instead of starting a turn that dies before reaching the model. Ordinary Codex turns on dashboard and subagent sessions no longer depend on the Gateway's session projection being warm. No config, schema, stored-data, or update change.

Why This Change Was Made

Codex resolves hosted web_search permission on every turn. It called the synchronous resolveWebSearchToolPolicy, which, for dashboard and subagent session keys, reads the session's stored delegation envelope. That read only succeeds inside a prepared capability read or when the Gateway session projection can serve the row. Normal turns usually found the projection warm. A turn resumed during startup, on a row recovery had just rewritten, did not, so the read threw. The prepared-read requirement arrived in #169622, and this caller (from #93446) was missed.

The policy owner now offers resolveWebSearchToolPolicyAsync, which prepares those stored facts before resolving, and Codex awaits it. No fallback reader is added; the synchronous SDK export is unchanged. Restart recovery itself was already correct (it started the run); the defect was entirely inside the harness turn.

Every other core caller of this policy was checked and is already covered: a prepared wrapper, a pre-resolved requester policy, or no session key.

SDK surface: one additive export on openclaw/plugin-sdk/agent-harness, so the export and callable budgets in scripts/plugin-sdk-surface-report.mts go up by 1 each. The bump was flagged to Peter before landing and accepted with the land instruction.

Incident trace

Seen on a production Gateway on 2026-10-18 after openclaw gateway restart --force. Main-session restart recovery logged decision=started, nextOwner=background-lane for an agent:main:dashboard:<uuid> session. About 2.6 s later agents/harness logged Codex agent harness failed; not falling back to embedded OpenClaw backend with the error above, and the lane task errored. The failing stack is buildDynamicTools → resolveWebSearchToolPolicy → resolveRequesterToolPolicies → resolveDelegatedPolicy (the senderless own-envelope read) → createSubagentSessionStore().get → readDurable. Startup at that moment showed agent-database queue waits around 9 s.

Release note: Codex sessions resumed by restart recovery no longer fail with "Session capability metadata requires worker preparation".

Evidence

  • Regression, red then green: run-attempt.dynamic-tools.test.ts › "prepares hosted search policy for a recovered dashboard turn". It runs a full Codex attempt with a fake app-server, using a recovered dashboard turn: restart-recovery provenance, hosted search enabled, no projection. On the base it fails with the production error and stack. With the fix the turn is accepted and completes. That also shows this was the only unprepared capability read on the recovered Codex attempt path.
  • Focused suites, all passing:
    • run-attempt.dynamic-tools.test.ts: 11 tests, about 69 s for the file on a loaded host; the new case takes about 6 s.
    • dynamic-tool-build.test.ts: 74 tests.
    • dynamic-tool-build.web-search.test.ts and dynamic-tool-build.sandbox.test.ts: 21 tests.
  • Gates, all passing:
    • tsgo:core
    • format check on the touched files
    • plugin-sdk:check-exports
    • plugin-sdk:surface:check
    • check:import-cycles
  • Review: Codex autoreview at P0–P2 came back scoped-clean.
  • Not run locally:
    • oxlint: the worktree install lacks eslint-plugin-solid.
    • tsgo:extensions: one unrelated qa-lab module-resolution error from the partial install; no errors in the touched files.
    • Live end-to-end restart: not run. Whether the projection serves the row is timing-dependent, so an isolated quiet Gateway would not reliably reproduce the failure on the base. The deterministic full-attempt regression covers that path instead.

@clawsweeper

clawsweeper Bot commented Oct 19, 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 scripts Repository scripts agents Agent runtime and tooling extensions: codex size: S labels Oct 19, 2026
Restart recovery resumed an interrupted Control UI dashboard session on the
Codex harness, and the turn failed with "Session capability metadata requires
worker preparation", leaving the session stranded.

Codex's dynamic tool build called the synchronous resolveWebSearchToolPolicy on
every turn that resolves hosted web_search. For dashboard and subagent keys that
policy reads the stored session envelope, which succeeds only inside a prepared
capability read or when the Gateway session projection can serve the row.
Ordinary turns usually found the projection warm; a turn resumed during startup,
on a row recovery had just rewritten, did not. The prepared-read requirement
arrived in #169622 and missed this caller.

Add resolveWebSearchToolPolicyAsync, which prepares the stored facts before
resolving, export it from the agent-harness SDK beside the unchanged sync
resolver, and have Codex await it. No fallback reader is added. The regression
runs a full Codex attempt for a recovered dashboard turn with hosted search on;
it fails on the base with the production error and passes with the fix.
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

The PR makes Codex await worker-prepared web-search policy so recovered dashboard turns can start without a warm session projection.

Example: Restart recovery resumes agent:main:dashboard:recovered before its session projection is available.

  • Before: The turn fails with “Session capability metadata requires worker preparation” before model execution.
  • After: Codex prepares the required session facts asynchronously before resolving hosted-search policy.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch appears correct, but fake app-server coverage does not satisfy the repository's required real-product recovery proof.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Restart recovery reports that a dashboard session resumed, but its Codex turn fails before reaching the model.
Reason: The incident and source establish a concrete recovery defect, and the maintainer-authored direction preserves the existing policy and storage owners.

Regression provenance

Possible regression — suspected (failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: current main retains the unprepared Codex policy read, and the patch supplies a focused repair with no definite introduced code defect found.

Priority: P1
Reviewed head: 241ac807d1d9b072309bfef4dbd4d4ae56f4f4ce

Before merge

  • Complete next step - Resolve GitHub's reported merge conflict for this PR.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted evidence that an isolated Gateway restart resumes a persisted dashboard Codex session through a real model turn with its session restrictions intact.
Agent review details

How this fits together

Restart recovery enters the Codex harness, whose dynamic-tool builder resolves core session and requester policy before configuring the native thread and starting the model turn.

flowchart TD
  A[Restart recovery] --> B[Codex attempt]
  B --> C[Dynamic tool builder]
  C --> D[Core web search policy]
  D --> E[Session capability worker]
  E --> D
  D --> F[Native thread and turn]
Loading

Technical review

Best possible solution:

Prepare the session facts through the existing worker owner before Codex resolves search policy, preserving the supported synchronous SDK contract.

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

The incident stack matches the current synchronous lookup and the session store's preparation requirement; the supplied regression targets that path, but this read-only review executed no target code.

Is this the best way to solve the issue?

The patch is a small owner-level repair: it reuses worker preparation, preserves policy calculation and public compatibility, and adds one distinct attempt regression without unnecessary production machinery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 44aa4e155b1d.

Provenance checked

  • Hosted-search policy and Codex caller keeps the original intent (1e0062b: feat: add Codex hosted web search #93446 introduced policy-controlled native hosted search while retaining managed-search fallback.)
  • Worker preparation requirement keeps the original intent (refactor: move bundled session reads and authority into workers #169622: Move ordinary bundled session reads to existing workers while keeping live authority at effects; local show/blame could not read some historical blobs, so attribution of the exact throwing line is unverified.)
  • SDK surface budgets keeps the original intent (075b466: The prior budget increase supported the shared message finality resolver; this PR retains that allowance and records a separately accepted additive async export.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a37a5a6 adds src/agents/web-search-tool-policy.ts:43 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a37a5a657531; files: src/agents/web-search-tool-policy.ts)
  • Jason (Json): Raw commit 1e0062b adds src/agents/web-search-tool-policy.ts:42 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: src/agents/web-search-tool-policy.ts)

PR surface

Source +12, Tests +26, Docs +8, Other +2. Total +48 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 15 3 +12
Tests 5 36 10 +26
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 2 +2
Total 10 63 15 +48

Review metrics

Metric Value Why it matters
Public SDK surface +1 export and +1 callable The async preparation entry point is additive, documented, and recorded as accepted; existing synchronous callers remain supported.

Labels

Label changes:

  • add P1: A reported production restart leaves interrupted dashboard Codex turns stranded before model execution.
  • add merge-risk: 🚨 compatibility: The PR expands the public agent-harness SDK; the accepted additive design retains the existing export and parameter contract.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: A reported production restart leaves interrupted dashboard Codex turns stranded before model execution.
  • merge-risk: 🚨 compatibility: The PR expands the public agent-harness SDK; the accepted additive design retains the existing export and parameter contract.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed October 18, 2026, 9:03 PM ET / October 19, 2026, 01:03 UTC.

@steipete
steipete force-pushed the fix/codex-recovered-web-search-policy branch from 241ac80 to de28c65 Compare October 19, 2026 01:12
@steipete
steipete marked this pull request as ready for review October 19, 2026 01:13
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T01:15:40.199048Z de28c65 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: de28c653c864b2583289c09da9e8bdb94e268a18
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/web-search-tool-policy.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@steipete
steipete merged commit 1ffa33e into main Oct 19, 2026
198 of 201 checks passed
@steipete
steipete deleted the fix/codex-recovered-web-search-policy branch October 19, 2026 01:49
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…penclaw#176707)

Restart recovery resumed an interrupted Control UI dashboard session on the
Codex harness, and the turn failed with "Session capability metadata requires
worker preparation", leaving the session stranded.

Codex's dynamic tool build called the synchronous resolveWebSearchToolPolicy on
every turn that resolves hosted web_search. For dashboard and subagent keys that
policy reads the stored session envelope, which succeeds only inside a prepared
capability read or when the Gateway session projection can serve the row.
Ordinary turns usually found the projection warm; a turn resumed during startup,
on a row recovery had just rewritten, did not. The prepared-read requirement
arrived in openclaw#169622 and missed this caller.

Add resolveWebSearchToolPolicyAsync, which prepares the stored facts before
resolving, export it from the agent-harness SDK beside the unchanged sync
resolver, and have Codex await it. No fallback reader is added. The regression
runs a full Codex attempt for a recovered dashboard turn with hosted search on;
it fails on the base with the production error and passes with the fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts security-sensitive-changed size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant