Skip to content

fix(cron): prevent cold turns from blocking the gateway - #123368

Merged
steipete merged 2 commits into
mainfrom
codex/startup-responsiveness-fix
Aug 13, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/startup-responsiveness-fix

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #120834

What Problem This Solves

Fixes an issue where the first isolated scheduled agent turn after Gateway startup could materialize the full live model catalog during model selection. On a source checkout, that broad discovery path can transform thousands of plugin modules, block the event loop for tens of seconds, and add hundreds of megabytes of heap before the runner starts.

Observed evidence on an affected Gateway included consecutive 56.1s and 53.6s liveness delays, a 39.9s health RPC, and a scheduled turn timing out after 60s before runner start.

Why This Change Was Made

resolveCronModelSelectionOwner lost its prior readOnly: true contract in #117587 when Gateway subagent binding was added. Without the flag, loadResolvedPublishedModelCatalogOwner is allowed to call the prepared snapshot's loadFullModelCatalog hook.

This restores readOnly: true while retaining allowGatewaySubagentBinding: true. Cron model selection now consumes the already-published configured catalog; the provider-scoped runtime-only thinking fallback added in #120834 remains unchanged.

Production LOC: +1/-0 (net +1) | Tests: +33/-7

User Impact

Cold scheduled agent turns no longer trigger broad provider discovery during owner selection, so they cannot starve Gateway HTTP/RPC responsiveness or spike memory through that path.

Evidence

  • Focused Vitest: 3 files, 65 tests passed.
  • Regression makes the owner-loader double fail if cron omits readOnly: true, and verifies loadFullModelCatalog is never invoked.
  • git diff --check, formatting, conflict-marker, dependency-pin, boundary, deprecated-API, wrapper-shadowing, dead-export, and related changed guards passed.
  • Local changed-gate core typecheck could not provide authoritative proof because the only available borrowed dependency tree predates current main (@openclaw/session-url-contract/parse missing, plus an unrelated terminal-core signature mismatch). Exact-head CI remains the typecheck authority.
  • Autoreview: clean, no accepted/actionable findings.

Provenance: clearly introduced by #117587 (code author/PR author/merger @steipete, 2026-08-01); #120834 repaired the sibling thinking-capability lookup but did not restore the owner lookup's read-only flag.

@clawsweeper

clawsweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 13, 2026
@steipete steipete self-assigned this Aug 13, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 13, 2026
@clawsweeper

clawsweeper Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 13, 2026, 7:31 PM ET / 23:31 UTC.

ClawSweeper review

What this changes

This PR makes isolated scheduled-agent model selection read the published model catalog without triggering full provider discovery, with regressions covering that contract.

Regression provenance

Possible regression — probable (reviewed change; failure trace; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for maintainer landing: the focused repair restores the cron model-owner read-only boundary and the prior release-note finding was removed, but exact-head CI is still running.

Priority: P1
Reviewed head: 49cb5935782620792fd15ac0a37bccb94f7afafd

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and directly regression-tested; remaining CI is a normal exact-head merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied focused tests still directly exercise the owner-selection contract.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied focused tests still directly exercise the owner-selection contract.
Evidence reviewed 4 items Focused repair: The proposed runtime change adds readOnly: true while retaining Gateway subagent binding for cron owner selection.
Regression coverage: The PR adds a failing full-catalog loader double and asserts cron owner selection is read-only across its affected test callers.
Prior finding addressed: The latest commit is chore: defer release changelog entry, and the supplied changed-file list contains no CHANGELOG.md path.
Findings None None.
Security None None.

How this fits together

A scheduled isolated agent resolves its model through the Gateway before its runner starts. This lookup must use the published catalog so a cold turn does not block Gateway responsiveness by loading the full provider catalog.

flowchart LR
  A[Scheduled agent turn] --> B[Model selection]
  B --> C[Gateway model owner]
  C --> D{Read-only lookup}
  D -->|Yes| E[Published catalog]
  D -->|No| F[Full provider discovery]
  E --> G[Start runner]
  F --> H[Gateway stall]
Loading

Before merge

  • Resolve merge risk (P1) - Until exact-head CI completes, the availability-sensitive model-selection boundary has not received full repository validation.
  • Complete next step (P2) - This is a maintainer-associated, availability-sensitive PR awaiting exact-head CI rather than a candidate for an automated replacement repair.
Agent review details

Security

None.

PR surface

Source +1, Tests +25. Total +26 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 0 +1
Tests 3 32 7 +25
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 33 7 +26

Review metrics

Metric Value Why it matters
Production vs test LOC production +1; tests +32/-7 The one-line behavior repair is backed by targeted contract regressions rather than a broader runtime rewrite.

Root-cause cluster

Relationship: canonical
Canonical: #123368
Summary: This PR is the focused remaining repair for cron owner selection after related model-catalog work addressed adjacent paths.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Wait for exact-head validation (recommended)
    Merge once the remaining exact-head checks confirm the restored read-only lookup preserves cron model selection.

Technical review

Best possible solution:

Land this narrow owner-boundary repair after exact-head CI confirms that cron uses the published catalog without affecting configured-model or Gateway-subagent selection.

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

Source-reproducible: the supplied regression makes an omitted read-only request invoke a failing full-catalog loader, although local runtime execution was unavailable in this review environment.

Is this the best way to solve the issue?

Yes: restoring the read-only request at the shared cron owner-selection boundary is narrower and safer than adding downstream timing or discovery guards.

AGENTS.md: unclear because the file could not be read completely.

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

Labels

Label justifications:

  • P1: The reported cold cron path can block Gateway health and RPC responsiveness and cause scheduled turns to time out.
  • merge-risk: 🚨 availability: The changed flag controls whether cron model selection may initiate costly full provider discovery on the Gateway event loop.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied focused tests still directly exercise the owner-selection contract.

Evidence

What I checked:

  • Focused repair: The proposed runtime change adds readOnly: true while retaining Gateway subagent binding for cron owner selection. (src/cron/isolated-agent/model-selection.ts:100, 49cb59357826)
  • Regression coverage: The PR adds a failing full-catalog loader double and asserts cron owner selection is read-only across its affected test callers. (src/cron/isolated-agent.model-formatting.test.ts:177, 49cb59357826)
  • Prior finding addressed: The latest commit is chore: defer release changelog entry, and the supplied changed-file list contains no CHANGELOG.md path. (49cb59357826)
  • Review limitation: Local read-only checkout inspection could not run because the execution sandbox failed while configuring loopback networking; this review therefore relies on the supplied PR diff and GitHub context.

Likely related people:

  • steipete: The provided related-history context identifies this person as author and merger of the model-owner refactor and both adjacent catalog-performance repairs. (role: feature owner and recent area contributor; confidence: high; commits: 6c9b38862d2d, 7a8eee4a363b; files: src/cron/isolated-agent/model-selection.ts)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-13T23:26:06.919Z sha 0ee216b :: found issues before merge. :: [P2] Remove the release-owned changelog entry

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 13, 2026
@steipete
steipete merged commit 1622c4f into main Aug 13, 2026
151 checks passed
@steipete
steipete deleted the codex/startup-responsiveness-fix branch August 13, 2026 23:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 14, 2026
)

* fix(cron): keep model owner lookup read-only

* chore: defer release changelog entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

1 participant