Skip to content

fix(state): agents refused with database repair advice when a config reload lands during startup - #193049

Merged
steipete merged 2 commits into
mainfrom
codex/issue-190307-admission-retry
Nov 4, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/issue-190307-admission-retry

Conversation

@steipete

@steipete steipete commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Related: #190307, #161921

What Problem This Solves

Fixes: an agent is refused with Plugin openai was reloaded or disabled and told to run openclaw doctor --fix on 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.model during admission.

Build Agents refused After settling
Published 2026.10.10 46 of 46, Prepared plugin generation retired before publication, doctor hint No restart; still ready: false 268 s later
Main ef4ccf4c7d2 main refused, Plugin openai was reloaded or disabled, doctor hint Hot-reload recovery restart re-admits all 46
This fix on main 9e379ebbc97, run 1 No plugin-lifecycle refusal; 4 retries logged Recovery restart; ready: true 36 s after it
This fix, run 2 No refusal; 4 retries logged Recovery restart; main still admitting 56 s after it when the run ended

Those 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:

Tests: src/gateway/server-agent-database-startup.preparation.test.ts adds 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, and tsgo core clean on Crabbox. The local pre-commit hook could not run because its tooling owner has a stale oxfmt, so format and lint ran on the box instead.

Review: $autoreview scoped-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.

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
@clawsweeper

clawsweeper Bot commented Nov 4, 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 gateway Gateway runtime size: S labels Nov 4, 2026
@steipete
steipete marked this pull request as ready for review November 4, 2026 22:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 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-11-04T23:02:16.178046Z 942e680 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug 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. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 4, 2026
@clawsweeper

clawsweeper Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Retry 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.

  • Before: A retired OpenAI plugin can leave an agent refused with advice to repair its healthy database.
  • After: Publication retries with fresh preparation facts; exhausted supersession recommends a Gateway restart instead of database repair.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-supported repair with reported native Gateway evidence, meaningful regression coverage, and no identified correctness or security defect.
Proof confidence 🐚 platinum hermit (4/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its public evidence records native Linux Gateway reload runs with seeded databases, avoided lifecycle refusals, and eventual readiness in one run. Those runs precede the final guidance-only narrowing, which has final-head regression coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Healthy agents can remain unavailable after a startup config reload and receive irrelevant database-repair advice.
Reason: The maintainer-authored direction addresses a demonstrated failure with a narrow extension of existing recovery behavior and explicitly leaves distinct incident mechanisms open.

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
Reviewed head: 942e680037f47c50e15099538acf6aba3fe2bfd9

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Gateway runtime-supersession handoff keeps the original intent (364cc68: Wait once for the current replacement, then retry through the bounded admission owner without repeating opening or migration.)
  • Publication retry classification keeps the original intent (7bad8ec: Replay schema-admission changes through fresh publication while retaining the existing four-attempt budget and stale-publication checks.)
  • Failure-specific admission guidance keeps the original intent (84806d0: Distinguish transient lock contention from corruption and other terminal failures instead of recommending unnecessary database repair.)
  • Startup health documentation keeps the original intent (4e1ba30: Follow model-runtime replacement during startup while preserving genuine replacement failures and shutdown behavior.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned PR scope: The introduced diff extends the existing lifecycle classifier and publication retry owner without changing database schemas, stored formats, configuration options, or public plugin APIs. (src/gateway/server-agent-database-startup.ts:245, 942e680037f4)
  • Current-main gap: Fetched main catches only PreparedModelRuntimePublicationSupersededError at this boundary, allowing sibling retired-generation and unavailable-instance failures to escape as terminal refusals. (src/gateway/server-agent-database-startup.ts:244, c8d2532608a2)
  • Preserved recovery contract: The four-attempt owner retains abortable delays, deletion checks, physical-file witnesses, and fresh preparation; genuine failures remain unwrapped and retain their existing guidance. (src/state/agent-database-startup.ts:484, 942e680037f4)
  • Native reproduction and accepted limit: The PR body records Linux Gateway runs with 46 seeded agents, constrained CPU, injected stalls, and a model config edit: stable and main produce lifecycle refusals, while both fix runs avoid them; one fix run reaches readiness after recovery restart. The maintainer explicitly retains four attempts and accepts exhaustion during a longer reload. (942e680037f4)
  • Focused regression coverage: The added case exercises real startup admission and its Gateway adapter with a retired-generation outcome and checks eventual admission; existing exhaustion and genuine initial/successor failure cases protect diagnostic separation. The body reports the regression and hint assertions fail on base and the suites pass on the final head. (src/gateway/server-agent-database-startup.preparation.test.ts:449, 942e680037f4)
  • Related incident remains distinct: Gateway restart leaves many agents permanently "degraded" (admission timeout), repair hint points to full doctor --fix #190307 documents migration worker timeouts, checkpoint failures, and Discord dead letters, including miniteatree's follow-up traces; this PR explicitly does not claim to reproduce or fix those failures.

Likely related people:

  • Peter Steinberger: Raw commit 0a3d000 adds src/gateway/server-agent-database-startup.ts:207 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0a3d0001c960; files: src/gateway/server-agent-database-startup.ts)
  • Dillon McCoy: Raw commit 364cc68 adds src/gateway/server-agent-database-startup.ts:215 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 364cc6843a07; files: src/gateway/server-agent-database-startup.ts)
  • weiqinl: Raw commit bcd4ccc adds src/state/agent-database-startup.ts:122 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: bcd4ccc17f25; files: src/state/agent-database-startup.ts)

PR surface

Source +23, Tests +24, Docs +2, Other +1. Total +50 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 30 7 +23
Tests 1 26 2 +24
Docs 1 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 7 60 10 +50

Labels

Label changes:

  • add P1: A config reload during startup can leave healthy agents unavailable until restart, breaking agent workflows with misleading database-repair guidance.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: A config reload during startup can leave healthy agents unavailable until restart, breaking agent workflows with misleading database-repair guidance.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 November 4, 2026, 6:16 PM ET / 23:16 UTC.

@steipete
steipete merged commit eb90c06 into main Nov 4, 2026
225 of 227 checks passed
@steipete
steipete deleted the codex/issue-190307-admission-retry branch November 4, 2026 23:29
@steipete

steipete commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…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
RomneyDa added a commit that referenced this pull request Nov 17, 2026
)

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]>
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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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