Skip to content

fix(agents): show Doctor's restore-first warning before deleting a held store - #207290

Merged
obviyus merged 2 commits into
mainfrom
core/agents-delete-restore-warning
Nov 28, 2026
Merged

obviyus merged 2 commits into
mainfrom
core/agents-delete-restore-warning

Conversation

@obviyus

@obviyus obviyus commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

What problem this solves

Follow-up to #207257. After deletion history is lost, Doctor holds back some agent stores and tells the operator to restore them first (openclaw agents add … to abort deletion and restore). openclaw agents delete on such an agent asked a plain "Delete agent?" with no hint of that, so a held store could be deleted without the user ever seeing Doctor's advice.

Change

  • Doctor's per-store restore-first guidance moved, unchanged, into formatHeldAgentStoreGuidance (src/commands/doctor-agent-deletion-held.ts). Doctor's journal repair calls it; nothing else formats it.
  • agents delete reads Doctor's recorded recovery holds (readAgentDeletionRecoveryHoldsInWorker, the same record agents add checks). For each held store of the agent:
    • Interactive: the confirmation starts with Warning: Doctor holds back a store of agent "<id>" because its deletion history was lost. Continuing deletes it without restoration:, then Doctor's guidance, then the usual question.
    • --force: the same warning is printed to stderr and deletion proceeds. --json stdout is unchanged.
  • Agents without a hold keep the ordinary confirmation.

Gateway: the CLI confirms locally before it calls the Gateway's agents.delete, so both CLI transports (through the Gateway and offline) show the warning. The Gateway method has no confirmation of its own.

Not covered: Control UI

The Control UI delete dialog does not show the held-store warning. The UI has no hold state on the wire, and adding a protocol field for it is deliberately parked (decision D56): the UI lists only configured agents while holds are mostly on unconfigured stores, deletion moves files to Trash, and Doctor already prints the restore-first guidance. Reopen if a real report shows a Control UI user deleting a held store.

User population

CLI users deleting an agent whose store Doctor holds back after a lost or unusable deletion journal.

Evidence

  • agents.delete.test.ts "shows Doctor's restore-first warning for a held store before confirming": a registered retired store, a reconstructed deletion journal that holds it, then agents delete retired.
    • Interactive: the confirmation contains Doctor holds back a store of agent "retired" and Doctor's openclaw agents add 'retired' … to abort deletion and restore; cancelling changes nothing. The configured ops agent (no hold) keeps Delete agent "ops" and prune workspace/state?.
    • --force --json: stderr carries the same warning; deletion proceeds and the registration is removed.
    • Red on main 98b9f17b: the confirmation has no warning.
  • doctor-agent-deletion-journal.test.ts and the rest of agents.delete.test.ts stay green (40 tests): Doctor's held-store text is byte-identical after the move.

…ld store

- agents delete reads Doctor's recorded recovery holds; the confirmation shows Doctor's guidance first, and --force prints it before proceeding.
- Doctor's per-store held guidance moves unchanged into one formatter shared by Doctor and agents delete.
@clawsweeper

clawsweeper Bot commented Nov 28, 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 commands Command implementations size: S labels Nov 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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-environment Preliminary submission classification; full source review pending. labels Nov 28, 2026
@clawsweeper

clawsweeper Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR shows Doctor’s existing restoration guidance before CLI deletion of an agent with held stores.

Example: Doctor holds the registered store of an unconfigured agent named retired.

  • Before: Deletion confirmation names remaining files but omits Doctor’s restoration advice.
  • After: Confirmation includes the restore-first warning; --force prints it to stderr before continuing.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful, focused implementation with no definite defects found; required CLI behavior proof is absent and failing CI remains incompletely diagnosed.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An operator can confirm deletion of a held store without seeing Doctor’s existing restoration advice.
Reason: The maintainer-authored direction adds useful context at the destructive-action boundary while retaining the accepted explicit-deletion behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a warning gap still present on main, and source review found no actionable code defects.

Reviewed head: 240faf00279c92fbf5e26d87615c044acde6307d

Before merge

None.

Findings

None.

Agent review details

How this fits together

The agent deletion CLI reads recovery holds from shared state, presents confirmation or forced-deletion warnings, then invokes the existing Gateway or offline deletion owner.

flowchart TD
  A[Operator CLI request] --> B[Agent deletion command]
  C[Recorded Doctor holds] --> B
  C --> D[Shared guidance formatter]
  D --> E[Confirmation or stderr warning]
  B --> E
  E --> F[Gateway or offline deletion]
  D --> G[Doctor diagnostics]
Loading

Technical review

Best possible solution:

Reuse Doctor’s guidance at the existing CLI confirmation boundary while preserving explicit deletion and its current lifecycle owner.

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

Current main confirms deletion without consulting recovery holds; the added regression exercises that missing warning, and the body reports it failing on the base, but this read-only review ran no target code.

Is this the best way to solve the issue?

The shared formatter is appropriate because Doctor and deletion need identical advice, and the patch preserves the existing recovery receipt and deletion owners without adding state or permission gates.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7cbf17b5819b.

Provenance checked

  • Doctor held-store guidance keeps the original intent (c6b21f6: Preserve stores after lost deletion history and direct operators through explicit restoration or deletion; later repairs distinguish internal artifacts and reserved agents.)
  • Explicit retirement of registered agents keeps the original intent (98b9f17: Allow an operator to retire an unconfigured agent through the journaled deletion owner rather than automatically discarding its registration.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 98b9f17 adds src/commands/agents.commands.delete.ts:130 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 98b9f17b6609; files: src/commands/agents.commands.delete.ts)

PR surface

Source +41, Tests +43. Total +84 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 87 46 +41
Tests 1 43 0 +43
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 130 46 +84

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.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • 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.

  • Supply the shipped-CLI evidence described in the proof assessment.
  • Diagnose the failing current-head checks and distinguish inherited failures from changes requiring repair.

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 28, 2026, 1:43 AM ET / 06:43 UTC.

@obviyus

obviyus commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: check-guards-architecture, check-lint-core-5, check-test-types-core-2 and openclaw/ci-gate fail on main in ui/ files this PR does not touch. The fix is #207294.

  • check-guards-architecture: an import cycle through ui/src/pages/skill-workshop/skill-workshop-page.tsx.
  • check-lint-core-5: ui/src/e2e/dashboard-widget-drop.e2e.test.ts:102 and ui/src/components/board/board-view.browser.test.ts:278.
  • check-test-types-core-2: ui/src/components/board/board-view.browser.test.ts(280,30) TS2345.
  • openclaw/ci-gate: gates on the three above.

This PR changes only src/commands/agents.commands.delete.ts, agents.delete.test.ts, doctor-agent-deletion-held.ts and doctor-agent-deletion-journal.ts. security-fast passes on this head, and every other check is green.

@obviyus
obviyus merged commit 568e7f1 into main Nov 28, 2026
118 of 123 checks passed
@obviyus
obviyus deleted the core/agents-delete-restore-warning branch November 28, 2026 07:06
vincentkoc added a commit that referenced this pull request Nov 28, 2026
* commit '262f14aab89ca286633992760fa45aeeded998f9': (207 commits)
  fix(ui): remove redundant type argument from Board browser test (#207352)
  test(channels): distinguish status and batch fixtures (#207232)
  fix(ui): type the Board drop test mock as void (#207348)
  fix(ui): break the Skill Workshop import cycle (#207345)
  test(channels): expose label guard regressions (#207195)
  fix: explain when a previous automation run keeps the agent from starting (#207180)
  refactor(test): consolidate loader proof and repair rollback coverage (#207152)
  fix(agents): one tool-result bound on every route, untrusted-content wrapper intact (#207101)
  test(plugins): verify staged SDK named exports (#207170)
  fix(ui): truncate empty Compose hints on narrow screens (#207301)
  fix: keep unsent Cmd+K Compose drafts when reopened (#207307)
  fix: explain chat update errors when a session changes (#206419)
  fix(ios): keep consecutive commands on one line in chat (#207242)
  fix(ios): keep connection messages from flashing when chat reopens (#207233)
  fix(ios): give Sessions groups more breathing room (#207221)
  fix(ui): show chat completions as activity rows (#201891)
  fix(ui): make empty composer hints look distinct from drafts (#207295)
  fix: explain why chat won’t attach an empty file (#206402)
  fix(agents): show Doctor's restore-first warning before deleting a held store (#207290)
  test(channels): fix join failure proof and trim probe fixture (#207264)
  ...
vincentkoc added a commit that referenced this pull request Nov 28, 2026
* commit '262f14aab89ca286633992760fa45aeeded998f9': (207 commits)
  fix(ui): remove redundant type argument from Board browser test (#207352)
  test(channels): distinguish status and batch fixtures (#207232)
  fix(ui): type the Board drop test mock as void (#207348)
  fix(ui): break the Skill Workshop import cycle (#207345)
  test(channels): expose label guard regressions (#207195)
  fix: explain when a previous automation run keeps the agent from starting (#207180)
  refactor(test): consolidate loader proof and repair rollback coverage (#207152)
  fix(agents): one tool-result bound on every route, untrusted-content wrapper intact (#207101)
  test(plugins): verify staged SDK named exports (#207170)
  fix(ui): truncate empty Compose hints on narrow screens (#207301)
  fix: keep unsent Cmd+K Compose drafts when reopened (#207307)
  fix: explain chat update errors when a session changes (#206419)
  fix(ios): keep consecutive commands on one line in chat (#207242)
  fix(ios): keep connection messages from flashing when chat reopens (#207233)
  fix(ios): give Sessions groups more breathing room (#207221)
  fix(ui): show chat completions as activity rows (#201891)
  fix(ui): make empty composer hints look distinct from drafts (#207295)
  fix: explain why chat won’t attach an empty file (#206402)
  fix(agents): show Doctor's restore-first warning before deleting a held store (#207290)
  test(channels): fix join failure proof and trim probe fixture (#207264)
  ...
vincentkoc added a commit that referenced this pull request Nov 28, 2026
* commit '262f14aab89ca286633992760fa45aeeded998f9': (207 commits)
  fix(ui): remove redundant type argument from Board browser test (#207352)
  test(channels): distinguish status and batch fixtures (#207232)
  fix(ui): type the Board drop test mock as void (#207348)
  fix(ui): break the Skill Workshop import cycle (#207345)
  test(channels): expose label guard regressions (#207195)
  fix: explain when a previous automation run keeps the agent from starting (#207180)
  refactor(test): consolidate loader proof and repair rollback coverage (#207152)
  fix(agents): one tool-result bound on every route, untrusted-content wrapper intact (#207101)
  test(plugins): verify staged SDK named exports (#207170)
  fix(ui): truncate empty Compose hints on narrow screens (#207301)
  fix: keep unsent Cmd+K Compose drafts when reopened (#207307)
  fix: explain chat update errors when a session changes (#206419)
  fix(ios): keep consecutive commands on one line in chat (#207242)
  fix(ios): keep connection messages from flashing when chat reopens (#207233)
  fix(ios): give Sessions groups more breathing room (#207221)
  fix(ui): show chat completions as activity rows (#201891)
  fix(ui): make empty composer hints look distinct from drafts (#207295)
  fix: explain why chat won’t attach an empty file (#206402)
  fix(agents): show Doctor's restore-first warning before deleting a held store (#207290)
  test(channels): fix join failure proof and trim probe fixture (#207264)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 29, 2026
…ld store (openclaw#207290)

## What problem this solves

Follow-up to openclaw#207257. After deletion history is lost, Doctor holds back some agent stores and tells the operator to restore them first (`openclaw agents add … to abort deletion and restore`). `openclaw agents delete` on such an agent asked a plain "Delete agent?" with no hint of that, so a held store could be deleted without the user ever seeing Doctor's advice.

## Change

- Doctor's per-store restore-first guidance moved, unchanged, into `formatHeldAgentStoreGuidance` (`src/commands/doctor-agent-deletion-held.ts`). Doctor's journal repair calls it; nothing else formats it.
- `agents delete` reads Doctor's recorded recovery holds (`readAgentDeletionRecoveryHoldsInWorker`, the same record `agents add` checks). For each held store of the agent:
  - Interactive: the confirmation starts with `Warning: Doctor holds back a store of agent "<id>" because its deletion history was lost. Continuing deletes it without restoration:`, then Doctor's guidance, then the usual question.
  - `--force`: the same warning is printed to stderr and deletion proceeds. `--json` stdout is unchanged.
- Agents without a hold keep the ordinary confirmation.

Gateway: the CLI confirms locally before it calls the Gateway's `agents.delete`, so both CLI transports (through the Gateway and offline) show the warning. The Gateway method has no confirmation of its own.

## Not covered: Control UI

The Control UI delete dialog does not show the held-store warning. The UI has no hold state on the wire, and adding a protocol field for it is deliberately parked (decision D56): the UI lists only configured agents while holds are mostly on unconfigured stores, deletion moves files to Trash, and Doctor already prints the restore-first guidance. Reopen if a real report shows a Control UI user deleting a held store.

## User population

CLI users deleting an agent whose store Doctor holds back after a lost or unusable deletion journal.

## Evidence

- `agents.delete.test.ts` "shows Doctor's restore-first warning for a held store before confirming": a registered `retired` store, a reconstructed deletion journal that holds it, then `agents delete retired`.
  - Interactive: the confirmation contains `Doctor holds back a store of agent "retired"` and Doctor's `openclaw agents add 'retired' … to abort deletion and restore`; cancelling changes nothing. The configured `ops` agent (no hold) keeps `Delete agent "ops" and prune workspace/state?`.
  - `--force --json`: stderr carries the same warning; deletion proceeds and the registration is removed.
  - Red on main `b4ec01fa`: the confirmation has no warning.
- `doctor-agent-deletion-journal.test.ts` and the rest of `agents.delete.test.ts` stay green (40 tests): Doctor's held-store text is byte-identical after the move.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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