Skip to content

fix: recover automations from deleted accounts with configured keys - #205592

Merged
roboclaw-bot merged 3 commits into
mainfrom
openclaw/stuck-automation-account-fix-261598
Nov 25, 2026
Merged

roboclaw-bot merged 3 commits into
mainfrom
openclaw/stuck-automation-account-fix-261598

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #205579

What Problem This Solves

After an automation's saved inference account is removed, editing it to a plain model reports success but leaves the deleted account bound. The next run fails even when a fresh job on that model works with the configured API key. The recovery message also recommends an account-listing command that refuses to run while the Gateway is online.

User Impact

An explicit plain-model edit can recover a deleted-account job onto an environment or provider-config key without recreating the job. Available accounts remain bound, including personal accounts. Unrelated edits and clearing the model override do not release the binding.

Recovery refuses another stored account or a missing credential instead of silently switching accounts or accepting a broken edit. Choosing a stored account still requires model@profile, and same-provider recovery cannot change the recorded runtime. Both account-error messages now point to openclaw gateway call models.authStatus. The deleted-account error also shows openclaw automations edit <jobId> --model <provider/model> for recovery onto an environment or provider-config key.

Why This Change Was Made

I kept the intentional account continuity introduced by #172590 and scoped recovery to an explicit edit after account removal. I reused the credential authorization owner, the existing route planner and the existing binding-clear operation. There is no new setting, schema, migration or automatic fallback.

Compatibility: CronStoredJob.inferenceBinding remains optional and its representation is unchanged. The existing src/cron/store/job-mutations.ts update path already deletes that field for an explicitly validated null binding, as used for native-login adoption. This change reuses that operation; it does not rewrite jobs on load or upgrade. The regression tests reopen the persisted job, and the separate Gateway run retained the existing job ID, schedule and history. I did not run an upgrade rehearsal.

I also updated the account-recovery documentation.

Evidence

  • The independent real-Gateway and scheduler reproduction on main d8fc8b7a5390 is described in Automations cannot recover from a deleted account using an existing static key #205579. I used that supplied reproduction rather than starting another Gateway.
  • I ran the regression assertions against unchanged main source at aecbf92d24e54dd24f3c93299209404f53f72367: all six failed for the expected behavior. The environment/config-key cases kept the deleted binding, the unsafe/no-credential edits incorrectly reported success, and both execution paths printed the offline-only hint.
  • On the recovery implementation, 99 tests passed across four focused files, including all six regression cases and existing personal-account, explicit-rebinding, runtime and credential-isolation coverage. Total wrapper wall time: 337.24 seconds. The Gateway owner suite took 251.41 seconds; the three cron suites took 81.92 seconds. These existing suites use the real SQLite/auth owners and reopen persisted jobs; they are not a live provider or scheduler run. Final-head CI completed successfully in 19 minutes 41 seconds (run 45716574064); that is workflow elapsed time, not per-test CPU time.
  • Production typecheck, the Gateway-method and cron-test typechecks, changed-file lint, formatting and git diff --check passed.
  • I ran the repository's pr-simplify author pass before final verification. The change reuses existing owners without a new recovery abstraction or test-only production seam. Delta against main: production +51 lines, tests +69 lines, docs +10 lines. The guidance change extends the existing error and its two execution-path regressions; the simplification pass required no extra helper or test scaffold.
  • On the final code, I reran the three cron files: 50 tests passed, including both removed-account paths checking the plain-model recovery command. Those two assertions fail without the message change. Test-wrapper wall time was 120.65 seconds (118.35 seconds inside Vitest). Production and cron-test typechecks, changed-file lint, formatting and git diff --check passed again.
  • Local independent review unavailable: autoreview could not launch Codex in its required read-only sandbox. I preserved the sandbox restrictions; no clean independent-review result is claimed.

Focused test command:

node scripts/run-vitest.mjs \
  src/gateway/server-methods/cron.inference-binding.test.ts \
  src/cron/isolated-agent.auth-profile-propagation.test.ts \
  src/cron/inference-binding.test.ts \
  src/cron/inference-binding-executor.test.ts --maxWorkers=1

External runtime verification

The separately supplied runtime check passed on aec99054cb5f across four isolated Gateways, using OPENAI_API_KEY in some and models.providers.openai.apiKey in others.

On main, removing the bound account and making a plain-model edit left both the manual run and the next scheduled run failing on the deleted account. With the PR, both runs succeeded on the static key. The job ID, schedule and history were preserved; a valid binding survived a plain edit; explicitly selecting another shared account worked; and adopting a personal account was refused.

I did not run those Gateways myself. The runtime logic is unchanged from that verified commit; the final delta adds only the plain-model recovery example and its assertions.

Not verified: rendered final-head error capture or real-provider billing. Final-head CI is green for c5b972de41ca526f0ec5844096b6240b73975a05, including openclaw/ci-gate, dependency review and security-sensitive review. ClawSweeper reviewed this exact head: ready for maintainer review, no findings and no before-merge items. Its remaining proof note asks for inspectable sanitized output from the separately run Gateways and a shipped-entry-point capture of the final diagnostic; those artifacts are not attached.

Contributor credit: reported and requested by Dan Riccio.

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

🦞 Made with OpenClaw

roboclaw-bot and others added 2 commits November 25, 2026 22:30
Worked on by:
- @daniel-lxs

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: 6c8fb229-2d87-4e9b-9db8-68f0e7f410d9
@clawsweeper

clawsweeper Bot commented Nov 25, 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 25, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 25, 2026
@clawsweeper

clawsweeper Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets explicit model edits release deleted automation-account bindings onto configured keys and supplies recovery commands that work online.

Example: An automation bound to deleted account openai:retired is edited to openai/gpt-4.1 with OPENAI_API_KEY configured.

  • Before: The edit succeeds but retains the deleted binding, so subsequent runs fail.
  • After: The validated edit clears the binding while preserving the job, allowing subsequent runs to select the configured key.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused implementation and regression coverage are sound, but the reported runtime verification lacks inspectable evidence.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An apparently successful model edit leaves an automation unusable after its saved account is deleted, despite an available configured key.
Reason: The maintainer-authored direction provides deliberate recovery without job recreation and preserves valid account and runtime restrictions.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR provides focused recovery for a deleted-account failure that current main still retains; source review found no discrete correctness defect.

Reviewed head: c5b972de41ca526f0ec5844096b6240b73975a05

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide inspectable sanitized output from the reported Gateway recovery runs and capture the final diagnostic through the shipped entry point; redact IPs, keys, phone numbers, and non-public endpoints.
Agent review details

How this fits together

The Gateway validates automation edits, the credential owner establishes account availability, the route planner selects authentication, and the scheduler persists the resulting binding for subsequent inference.

flowchart TD
  A[Automation model edit] --> B[Gateway admission]
  B --> C[Credential lifetime owner]
  C --> D[Authentication route planner]
  D --> E[Scheduler job persistence]
  E --> F[Manual or scheduled inference]
Loading

Technical review

Best possible solution:

Retain the narrow explicit recovery path through the existing credential, route-planning, and scheduler mutation owners.

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

The linked report describes real scheduled failures, and current-main source independently shows plain-model edits retaining the retired binding that same-provider execution requires; this review executed no target code.

Is this the best way to solve the issue?

The implementation fixes the edit boundary using existing owners, preserves intentional account continuity, and introduces no competing persistence path or new option.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1bc412fb7478.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned change and current main: The introduced diff adds explicit retired-account recovery; fetched main still returns without replacing the binding on a plain-model edit. (src/gateway/server-methods/cron-input-validation.ts:565, c5b972de41ca)
  • Reported production failure: The report credits Dan Riccio and describes a real Gateway/scheduler comparison: editing retains the deleted account, fresh creation succeeds with the static key, and models.authStatus works online. See Automations cannot recover from a deleted account using an existing static key #205579.
  • Recovery boundaries: Recovery requires an explicit model without a profile selection, an existing binding, no simultaneous agent move, and the credential owner's retired result; configured-key capture checks same-provider runtime continuity before authorizing removal. (src/gateway/server-methods/cron-input-validation.ts:565, c5b972de41ca)
  • Verified no-migration case: Release v2026.11.10 already has optional CronStoredJob.inferenceBinding and the update operation that deletes it for a validated null binding; this PR changes neither representation nor load-time migration. (src/cron/store/job-mutations.ts:296, 6ea542fd97e2)
  • Regression coverage: Handler tests cover environment/config-key recovery, preserved valid and personal bindings, unrelated edits, model clearing, rejected stored-account switching, rejected missing credentials, and persisted job identity; execution tests check actionable recovery guidance on embedded and CLI routes. (src/gateway/server-methods/cron.inference-binding.test.ts:235, c5b972de41ca)
  • Runtime evidence and re-review delta: The full PR body reports successful manual and scheduled recovery across four isolated Gateways at aec9905, but supplies no terminal/log artifact and explicitly leaves final-head error capture unverified; comparison confirms the later code change only extends the diagnostic and its assertions. The supplied body identity is a70c116d883e40697e81a6fe2a279e319efa3a407b2985918fa35625e5736670. (src/cron/inference-binding.runtime.ts:331, c5b972de41ca)

Likely related people:

  • Jason (Json): Raw commit d25a316 adds src/cron/inference-binding.runtime.ts:13 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d25a316fc7c3; files: src/cron/inference-binding.runtime.ts)
  • Vincent Koc: Raw commit f691027 adds src/cron/inference-binding.runtime.ts:115 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f691027b66ad; files: src/cron/inference-binding.runtime.ts)
  • Ayaan Zaidi: Raw commit e8ff306 adds src/cron/run-inference.ts:118 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e8ff306f7413; files: src/cron/run-inference.ts)

PR surface

Source +51, Tests +69, Docs +10. Total +130 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 61 10 +51
Tests 2 70 1 +69
Docs 2 13 3 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 144 14 +130

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #205579
Summary: This PR addresses the concrete deleted-account recovery report; the broader explicit-account redesign overlaps the subsystem without superseding this focused repair.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • merge-risk: 🚨 auth-provider: An explicit recovery edit changes the credential route from a retired stored account to a configured key; the maintainer-authored direction accepts this narrowly validated transition while preserving available bindings.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Attach the existing sanitized runtime evidence and a final diagnostic capture.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-25T22:47:27.690Z sha aec9905 :: blocked before merge. :: none

Reviewed November 25, 2026, 6:18 PM ET / 23:18 UTC (Revision 2).

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Nov 25, 2026
@roboclaw-bot
roboclaw-bot merged commit 04b854b into main Nov 25, 2026
155 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/stuck-automation-account-fix-261598 branch November 25, 2026 23:42
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 impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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.

Automations cannot recover from a deleted account using an existing static key

1 participant