Skip to content

fix(gateway): keep readiness false while required agents prepare - #171063

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-ready-but-cannot-dispatch-20260919
Oct 13, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-ready-but-cannot-dispatch-20260919

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

/readyz could return 200 while a required agent's database was still preparing and chat.send rejected the turn with agent-database-inspection-pending.

User Impact

Required-agent startup preparation now keeps /readyz at 503 with the existing agent-specific diagnostic. The listener, Control UI, and admitted agents remain usable; optional agents still do not hold readiness. Recovery and resume scheduling are unchanged.

Why This Change Was Made

Remove the normal-Gateway exemption for pending admission and consume the same required-agent refusal facts that dispatch enforces. Canary readiness was already strict. Update verification already waits for /startupz before readiness, so this adds no new updater wait or startup dependency. Production delta: −7 lines, with no new state, timers, configuration, or schema changes.

Evidence

Synthetic Linux sandbox measurements on fc4e122aac62 and current main df8c7ddb5d68 reproduced the mismatch independently of event-loop saturation. HTTP readiness returned 200 while WebSocket chat.send refused the required agent. After admission, a new turn reached the reply dispatcher while subagent restoration remained deliberately blocked, both before and after this change.

Probe sample (100,000 checks, median of 7 rounds) Before After
Required agent pending: false-ready checks 100,000 0
Required agent pending: time per check 80 ns 78 ns
Healthy: time per check 72 ns 64 ns

Treat the tiny timing differences as neutral; this is a readiness correctness fix. The older baseline measured 69 ns healthy / 82 ns pending and also returned 100,000 false-ready results. The existing startup integration fixture's two recovery scenarios passed on both unmodified revisions and the changed code. Measurements used synthetic state and constrained CPU/memory in the operator-authorized sandbox; no production state or Testbox/Crabbox leases were used.

The three changed readiness assertions fail on the original implementation. Local validation: changed-file formatter, repository scoped lint, and pnpm test src/gateway/server/readiness.test.ts src/gateway/server-agent-database-startup.test.ts --maxWorkers=1 — 34/34 passed, 193.36 s wall time (185.93 s Vitest time). The existing startup file owns real Gateway/worker lifecycle and cleanup; its complete 13-case run accounts for the longer duration. The change reuses that fixture without adding a boot. Full exact-head PR CI passed, including typechecks, lint, changed/boundary tests and UI E2E: 743 s elapsed for the whole run. Security and dependency checks also passed; no CI reruns or inherited-failure exception were needed. No new test file or exported surface was added.

Review: independent subagent review (autoreview route unavailable); clean at P0–P2.

Limits: the reply provider is mocked at the existing integration boundary. This does not fix the separately investigated event-loop wedge, nor certify external provider availability or unrelated pending model acquisition. Slow startup-sidecar scheduling is preserved because the non-wedged repro showed that it does not itself prevent new dispatch.

@clawsweeper

clawsweeper Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review October 13, 2026 13:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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-13T13:18:17.589857Z 5428f91 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 13, 2026
@steipete
steipete merged commit a4d90fb into main Oct 13, 2026
188 of 189 checks passed
@steipete
steipete deleted the steipete/perf-micro-ready-but-cannot-dispatch-20260919 branch October 13, 2026 13:29
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
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 gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant