Repository navigation
fix(state): agents refused with database repair advice when a config reload lands during startup - #193049
Conversation
A config reload during startup admission could retire the plugins behind an agent's secrets and model publication. Admission treated that as a terminal failure, refused the agent, and told the operator to repair a healthy database. Retry those lifecycle failures through the existing bounded publication retry, with a short delay while the reload settles. A publication that still fails now names the runtime problem and a Gateway restart instead of doctor --fix. Refs #190307
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesRetry plugin-lifecycle failures during agent startup publication and recommend restarting the Gateway when supersession exhausts the retry budget. Example: An operator changes agents.entries.a03.model while 46 agents are completing startup admission.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a demonstrated startup-reload failure still present on main; no actionable patch defect was found. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway adapter prepares secrets and model runtimes for deferred agents; the state admission owner coordinates preparation and publishes availability or a typed refusal. flowchart TD
A[Config reload] --> B[Plugin generation replacement]
B --> C[Gateway startup adapter]
C --> D[Bounded admission retry owner]
D --> E[Fresh secrets and model preparation]
E --> F[Agent available]
D --> G[Failure-specific refusal]
Technical reviewBest possible solution: Use the existing bounded publication owner for reload-lifecycle failures while preserving genuine database diagnostics and tracking unrelated timeout incidents separately. Do we have a high-confidence way to reproduce the issue? Source confirms the lifecycle-classification gap on current main, and the PR records native stable/main reproductions under a startup config reload; this review executed no target code. Is this the best way to solve the issue? The patch is a focused repair using the existing lifecycle classifier, retry budget, cancellation mechanism, and refusal owner, with no competing recovery path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c8d2532608a2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +23, Tests +24, Docs +2, Other +1. Total +50 across 7 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 4, 2026, 6:16 PM ET / 23:16 UTC. |
|
Merged via squash.
|
…reload lands during startup (openclaw#193049) * fix(state): recover agent admission when a reload retires its plugins A config reload during startup admission could retire the plugins behind an agent's secrets and model publication. Admission treated that as a terminal failure, refused the agent, and told the operator to repair a healthy database. Retry those lifecycle failures through the existing bounded publication retry, with a short delay while the reload settles. A publication that still fails now names the runtime problem and a Gateway restart instead of doctor --fix. Refs openclaw#190307 * fix(state): keep repair guidance for genuine publication failures
) Retry plugin lifecycle failures through the existing bounded startup publication path. Exhausted runtime churn recommends restarting the Gateway rather than repairing a healthy database; genuine failures retain repair guidance. Refs #190307. (cherry picked from commit eb90c06) Co-authored-by: RomneyDa <[email protected]>
Related: #190307, #161921
What Problem This Solves
Fixes: an agent is refused with
Plugin openai was reloaded or disabledand told to runopenclaw doctor --fixon a healthy database when a config reload lands while that agent is finishing startup admission.User Impact
User impact: agents admitted during a config reload now retry their runtime publication instead of being refused. If reloads keep replacing the publication past the retry budget, the refusal asks for a Gateway restart rather than a database repair, because Doctor cannot fix that condition.
Why This Change Was Made
Startup admission already retries runtime publication when a model publication is superseded (#172632), but it did not recognize the sibling outcomes of a reload: a retired plugin generation or an unavailable plugin instance. Those escaped as terminal failures. This change uses the existing lifecycle classification at that boundary and adds a short backoff (0.5, 1, 2 s, abortable) so a reload can settle between attempts. Publication reads secrets and models and does not write the agent database, so replaying it is safe.
Genuine publication failures still surface once with their existing guidance, including lock, ownership, and corruption classification. Only exhausted supersession gets the new restart hint.
Accepted edge: the retry budget stays four attempts, so a longer reload can still exhaust it. The hot-reload recovery restart re-admits those agents.
Evidence
Native proof on Crabbox AWS Linux: 46 seeded agents (17-200 MB) deferred at startup, Gateway pinned to 2 CPUs, main thread stalled 1.5 s in every 2 s by a proof-only preload, and one
openclaw config set agents.entries.a03.modelduring admission.Prepared plugin generation retired before publication, doctor hintready: false268 s lateref4ccf4c7d2mainrefused,Plugin openai was reloaded or disabled, doctor hint9e379ebbc97, run 1ready: true36 s after itmainstill admitting 56 s after it when the run endedThose two fix runs used the earlier build of this branch. The final head changes only which failures get the restart hint. Regression coverage is on the final head.
Same fleet with no config edit: 46 of 46 admitted on 10.10 under 2 CPUs with 8 s stalls, SIGKILL, and RPC load. So the trigger is the reload, not fleet size.
Not fixed here, and observed on every build under this load:
config setstill returnspersisted but was not applied to the active Gateway, and main restarts the Gateway once to recover.worker task timed outorcheckpoint expiredrefusals reported in Gateway restart leaves many agents permanently "degraded" (admission timeout), repair hint points to fulldoctor --fix#190307 on 10.9, so they stay open there.Tests:
src/gateway/server-agent-database-startup.preparation.test.tsadds the retired-generation retry, and exhausted supersession now asserts the restart hint. The retired-generation test and the hint assertions fail on base. Those suites pass 28/28, with lint, format, andtsgocore clean on Crabbox. The local pre-commit hook could not run because its tooling owner has a staleoxfmt, so format and lint ran on the box instead.Review:
$autoreviewscoped-clean. An independent Codex review found one P2, that wrapping every publication error hid lock and corruption guidance. That is fixed, and its re-review found nothing.The 24 added test lines carry an allocation in
config/test-lines-allocations/agent-admission-plugin-reload.txt.