Skip to content

fix(gateway): keep health responsive during context cache warmup - #119562

Merged
fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:codex/fix-gateway-context-owner-prewarm-20260805-a1
Aug 5, 2026
Merged

fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:codex/fix-gateway-context-owner-prewarm-20260805-a1

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

Closes #119375

What Problem This Solves

Fixes an issue where a ready Gateway could delay health, readiness, RPC, and channel work while optional post-ready context-window cache warming processed a large model catalog.

Why This Change Was Made

The post-ready warmup now reuses the Gateway-published prepared catalog owner and its committed config generation. This avoids constructing a read-only fallback owner that hashes the full model configuration, while preserving exact request-time loading, cache generation checks, and shutdown cancellation.

This is intentionally separate from #119377, which removed the sibling provider session-catalog prewarm. Fresh canonical main remained red for the context-window cache path after that merge.

User Impact

Operators can expect health, readiness, and Gateway RPC activity to remain responsive during optional context cache warming, while model context-window metadata still converges to the configured values.

Evidence

No config, protocol, storage, or public API surface changes.

AI-assisted: yes. I understand the change and verified the lifecycle owner, request-time fallback, generation, cancellation, and sibling startup paths.

@fuller-stack-dev fuller-stack-dev self-assigned this Aug 5, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 5, 2026
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 5:37 AM ET / 09:37 UTC.

ClawSweeper review

What this changes

The PR makes post-ready context-window cache warming reuse the Gateway’s published model-catalog owner instead of constructing a config-keyed fallback owner.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. The patch addresses a reproduced P1 Gateway responsiveness defect with a lifecycle-owner reuse path; no actionable correctness or security finding was found. It is maintainer-authored and still awaiting completion of exact-head checks.

Priority: P1
Reviewed head: 28e788b71b551785c9eccb56b9232c40ce877bfc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong real Gateway evidence and a focused owner-boundary fix support a normal merge-quality rating.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides an exact-head real Gateway red/green benchmark with responsive probes, correct metadata, and zero errors.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides an exact-head real Gateway red/green benchmark with responsive probes, correct metadata, and zero errors.
Evidence reviewed 6 items Current-main behavior: Current main schedules the post-ready warmup with startup config and invokes the exact read-only catalog-owner path, which can require a config-keyed fallback build.
Candidate owner boundary: The PR keeps ordinary request-time loading exact, while its post-ready path asks for the Gateway-published owner and stages its catalog atomically.
Published-owner contract: A read-only catalog request first attempts the compatible full lifecycle owner; only a miss acquires an ephemeral read-only fallback. Gateway startup publishes the compatible owner with the required binding.
Findings None None.
Security None None.

How this fits together

After Gateway readiness, an optional idle task warms model context-window metadata. It should consume the already-published catalog without delaying health, readiness, RPC, or channel traffic.

flowchart LR
  A[Gateway startup] --> B[Published model catalog]
  A --> C[Gateway ready]
  C --> D[Idle warmup scheduler]
  D --> E[Reuse published catalog]
  E --> F[Context-window cache]
  C --> G[Health, RPC, and channels]
Loading

Before merge

  • Resolve merge risk (P1) - Required exact-head checks were still in progress; merge only after they complete successfully.
  • Complete next step (P2) - No mechanical repair is indicated; this maintainer-owned PR needs normal exact-head CI completion and merge review.
Agent review details

Security

None.

PR surface

Source +67, Tests +66. Total +133 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 85 18 +67
Tests 2 83 17 +66
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 168 35 +133

Review metrics

Metric Value Why it matters
Production vs test LOC production +85/-18, tests +83/-17 The production growth establishes the published-owner and cancellation boundary; the paired tests cover its exact and post-ready paths.

Stored data model

Persistent data-model change detected: persistent cache schema: src/agents/context.lookup.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep request-time catalog loading exact and use the already-published Gateway catalog only for optional post-ready warming, then validate the exact head before merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep request-time catalog loading exact and use the already-published Gateway catalog only for optional post-ready warming, then validate the exact head before merge.

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

Yes. The PR documents a current-main real Gateway reproduction with a large synthetic catalog and measured multi-second health, readiness, and RPC delays.

Is this the best way to solve the issue?

Yes. Reusing the lifecycle-published catalog is narrower than removing cache warming or redesigning the cache scheduler, while preserving exact request-time loading.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c02e39345bf6.

Labels

Label changes:

  • add P1: The patch targets a reproduced multi-second delay of ready Gateway health, readiness, RPC, and channel work.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides an exact-head real Gateway red/green benchmark with responsive probes, correct metadata, and zero errors.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides an exact-head real Gateway red/green benchmark with responsive probes, correct metadata, and zero errors.

Label justifications:

  • P1: The patch targets a reproduced multi-second delay of ready Gateway health, readiness, RPC, and channel work.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides an exact-head real Gateway red/green benchmark with responsive probes, correct metadata, and zero errors.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides an exact-head real Gateway red/green benchmark with responsive probes, correct metadata, and zero errors.

Evidence

What I checked:

  • Current-main behavior: Current main schedules the post-ready warmup with startup config and invokes the exact read-only catalog-owner path, which can require a config-keyed fallback build. (src/agents/context.ts:189, c02e39345bf6)
  • Candidate owner boundary: The PR keeps ordinary request-time loading exact, while its post-ready path asks for the Gateway-published owner and stages its catalog atomically. (src/agents/context.ts:273, 28e788b71b55)
  • Published-owner contract: A read-only catalog request first attempts the compatible full lifecycle owner; only a miss acquires an ephemeral read-only fallback. Gateway startup publishes the compatible owner with the required binding. (src/agents/prepared-model-catalog.ts:152, 28e788b71b55)
  • Regression coverage: Tests distinguish ordinary exact loading from published-owner warming and cover idle deferral plus stop-before-run cancellation. (src/agents/context.lookup.test.ts:380, 28e788b71b55)
  • Observed behavior proof: The PR body reports an exact-head real Gateway fixture with 200,000 synthetic models: health/readiness/RPC p99 fell from 3319/3590/2451 ms on the control to 59.04/58.90/53.84 ms with correct metadata and no errors. (28e788b71b55)
  • Current-main and history status: The candidate is one commit ahead of current main and is not merged; local history identifies the original post-ready cache warmup as commit 6b506e9. (src/gateway/server-startup-context-cache-prewarm.ts:16, 6b506e9070fc)

Likely related people:

  • fuller-stack-dev: Authored the current PR and prior merged Gateway responsiveness work in the same post-ready startup area. (role: recent Gateway warmup contributor; confidence: high; commits: 77f7560b4184, 287da89fabba; files: src/gateway/server-startup-post-attach.ts, src/gateway/server-startup-context-cache-prewarm.ts)
  • steipete: Recent history shows sustained work on the prepared model-runtime and catalog lifecycle that this patch reuses. (role: prepared model runtime contributor; confidence: medium; commits: af588720525e, 06f5f73e4731; files: src/agents/prepared-model-catalog.ts, src/agents/prepared-model-runtime.ts)

Rank-up moves

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

  • Wait for the remaining required checks on the exact head before merging.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@fuller-stack-dev
fuller-stack-dev merged commit c45b0a1 into openclaw:main Aug 5, 2026
134 of 141 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

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

Labels

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gateway post-ready context cache warming can starve event loop

1 participant