Repository navigation
fix: let a new bot take over a deleted bot's kept memory - #33148
Conversation
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
a5bde1f to
2361509
Compare
|
[operator: bolichen97]
AI-assisted, posted on behalf of bolichen97 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: giving the kept store a new owner by reusing its recorded member id fixes the stranding where it starts. Nothing is copied, existing creates behave as before, and the new surface comes with rendered evidence. Notes
[DESIGN-REVIEWED] 93d3a11 Description read[DESCRIPTION-READ] 6a7b92e7910b4ecef77b1a4659bf80204a2c741027adfd14bbc4c746b54a75b4 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The default stays a fresh store and every new surface has exactly one counted consumer. The one premise risk is the framing: this is labelled a fix but it adds a capability. Notes
What this change shipsInventory (9 items) — 8 justifiedIntent: a person who deletes a bot and makes a new one gets the deleted bot's kept memory back. This is an ADDITION framed as a FIX.
[FIRST-PRINCIPLES-REVIEWED] 93d3a11 Description read[DESCRIPTION-READ] e665d33f33aec7b99062d23b9a69f7e9b9aebbaeacdd1b9afac9a8e62ee4bb31 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. The blind reader understood the new Memory choice and the updated delete text, and all of them appear in screenshots in both themes. The reader's hesitation over the dropdown was about the choice being one-time, which it is. Notes
[UX-REVIEWED] 93d3a11 Description read[DESCRIPTION-READ] 470b60bf5cf55eb0370f48d8ce42a1eab5d610142f2b9deab5d70285f6b0c19c That sha256 names everything this verdict read: the PR description, plus the 22 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
2361509 to
2ae052c
Compare
|
[operator: bolichen97]
AI-assisted, posted on behalf of bolichen97 |
|
[operator: bolichen97]
AI-assisted, posted on behalf of bolichen97 |
2ae052c to
2bfaf89
Compare
|
Rebased: main moved in src/kiro_crew/docs/ui-index.generated.json since this head was pushed, and the PR stopped merging (27e9359 -> 9657892); CI re-running. |
|
0cb5484 to
7e9ea2e
Compare
|
resolution: removed -- the ownerless-store listing skips an entry it cannot resolve instead of failing every row; F1 is rebutted and the check-in reset stays after publish
|
|
Rebased: main moved in docs/feature-map/README.md since this head was pushed, and the PR stopped merging (9657892 -> a45e97a); CI re-running. |
|
Re-sync budget reset |
|
self-added: no
|
7e9ea2e to
2fe1621
Compare
|
Rebased: main moved in src/kiro_crew/docs/ui-index.generated.json since this head was pushed, and the PR stopped merging (a45e97a -> 8579038); CI re-running. |
|
Rebased: main moved in docs/feature-map/README.md and src/kiro_crew/docs/ui-index.generated.json since this head was pushed, and the PR stopped merging (8579038 -> 197cde9); CI re-running. |
Deleting a bot keeps its memory store on disk, but every route into a member store resolves it through its live owner, so the kept store could not be opened, exported, restored or picked again, while the delete text read as if the memory were safe. A new bot created from the dashboard can now take over a kept store that no bot owns: the New bot dialog offers it under Advanced settings, POST /api/agents binds the new bot to the store's recorded member id, and GET /api/memory/ownerless-stores lists what is on offer. Nothing is copied. The create clears every approval grant on that thread's session and closes the deleted bot's thread still live on that key, so its pin and grants do not carry over, and the delete text says a new bot can start from the memory. Builds on #22947 by @mbriones98.
|
Rebased: main moved in docs/feature-map/README.md and website/src/test/ApiClient.refactor.surface.test.ts since this head was pushed, and the PR stopped merging (197cde9 -> 301f9ab); CI re-running. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
I reviewed head 93d3a11 and found nothing blocking. Both the create route and the new kept-store listing are owner-gated. Only a store no configured bot owns or could share an identity with can be adopted, and its database identity must match its record. The cross-process locked write runs the same checks again, so a store with a live owner can never be claimed. A create that fails leaves the kept store, its database and its offer entry exactly as they were. The deleted bot's approval grants are cleared before anything is published, and if they cannot be cleared the create is refused. I ran the new adoption tests with the related binding and thread suites on this head and all of them pass.
Problem / Motivation
Goal: A deleted bot's kept memory gets a supported way back: a new bot created on the dashboard can take it over, and the delete text says so.
The delete dialog says a bot's memory is kept, and on disk it is. But every route into a member store resolves it through its live owner, so once the bot is gone nothing can open that store again: it is missing from the Copy memories dialog and the memory picker,
memory exportandmemory restorerefuse it,memory importcannot carry its facets, and a create always makes a fresh store.Why it matters
The safe-sounding delete strands the memory. A user who deletes a bot and makes it again (the only repair for #22486) loses every memory row it had, with no supported way to get them back.
Not a goal
kirocrew agent createruns outside the gateway, so it cannot close the deleted bot's thread that is still live there; the dashboard create is the one route.memory export --include-markdown).What changed (motivation → approach → change)
POST /api/agentsadopt_memory_store: the new bot owns that kept store, nothing copiedGET /api/memory/ownerless-storesname,former_owner), owner-gated. The dialog reads that gate's 403owner_onlyas nothing kept: no Memory field, no noticeA deleted bot's store could not be reached because a member store is addressed through its owner's member id: the delete removes the owner and keeps the store, and nothing could give the store an owner again.
Picking a kept memory now makes the new bot its owner: the new bot is created on the store's recorded member id, so the database, its rows, its backups and its chat thread are used as they are (
member_memory_adopt.py). Only a store nobody owns is offered or accepted: no bot holds its id or uses it, no older bot without a member id has a name that maps to that id, its database carries exactly the recorded identity, and no kept thread is filed under a former name. The create's locked write inmemory_stores.pychecks the same against the config on disk, so a bot written by another process in the meantime wins. A create that fails leaves the kept store as it was. The dialog reads the offer throughapi/client/memory.ts, and a pick the server refuses as unusable (409adopt_memory_unavailable) resets it to an empty memory and reloads the list, while a failure after the store's own checks keeps the pick; its strings are in all twelve catalogs (locales/en.jsonand its translations), and the generatedui-index.generated.jsoncarries the new delete text. Each delete (the dashboard,kirocrew agent delete, the installed-agent sync ininstalled_agents.py) writes the name the bot showed onto its kept store asformer_owner, a new display-only field of the store record (config/memory_sections.py), so a bot named "审查员" is offered by that name, not by its config key, which for such a name is a hash.The new bot reuses the deleted bot's member id and store, so its chat thread has the same key. Before saving anything, the create clears every approval grant on that thread's session (Trust, Trust reads, an app's scoped grant and the session's stored approval policy) on every slot whose turns run on it, whether or not the thread is still open: a workflow slot linked to that session outlives a closed thread. When the thread is still open in the gateway, the create then closes it, the way closing a tab does (
retire_stale_member_slotinmembers_thread.py). It is refused (409member_thread_busy) when the grants cannot be cleared or the close fails. The next open restores the conversation under the new bot's name, with the approval mode set from the new bot's settings, never the deleted bot's grant. Its goals follow it too, but any check-in switch still on is turned off, since the delete removed those check-ins and nothing should start them again unasked. The create's audit row names the adopted store. The memory, config, crew-mode and dashboard specs, the Bots guide (crew-members.md) and the feature map describe the route, and the delete-cleanup docstring increw_removal.pyno longer says the memory store is deleted.Backwards compatibility
Compatible:
adopt_memory_storeis optional, and leaving it out keeps the fresh store every create makes today; the delete text changes wording only.former_ownerdefaults to empty (config-baseline.jsonlists it), and its one reader is the kept-store offer, which loads the config at request time, so no applier or restart mark is needed. A create that leaves it out runs the same locked-write checks as on main.Removes nothing: no route, field, record or setting is taken away.
Tests
test/test_member_memory_adopt.py: create, delete, then create with the kept store, and the new bot owns the same store and member id, its thread binding follows it, and the store leaves the offer list; the deleted bot's goal follows with its check-ins off; a deleted bot's live thread opens as the new bot; a same-name adopt keeps no approval grant from the deleted bot, on its thread or on a slot sharing that session, and is refused with nothing saved when its thread cannot be closed; an adopt clears Trust, Trust reads, a scoped grant and the stored policy on a linked slot of that session, with the thread open or closed, and leaves a slot on another session alone; the offer names a bot by the name it showed after a dashboard or a CLI delete, and an adopt clears it; a same-name create without asking still gets a fresh store; refusals for a store with an owner, a second adopt, an unknown or default store, a malformed name, a mismatched database identity, a store an older bot would share an identity with, and a thread filed under a former name; the locked write's re-checks; a failed create keeps the store; the list is owner-gated, leaves out a store whose folder is gone, and leaves out one whose folder redirects through a link while still listing the others.NewCrewmateDialog.test.tsx: no Memory field when nothing is kept, a failed list read named in the options notice, an owner-only refusal of the list shown as nothing kept, the empty-memory default sends no adopt, a pick sendsadopt_memory_store, and a refused pick resets and reloads.CrewEditorNextDialog.test.tsx: the danger-zone note and the delete confirmation say a new bot can start from the memory.test/test_member_memory_adopt.pypassed 20/20 at-n0, 10/10 at-n 4 --dist loadgroup --max-worker-restart=2besidetest_crew_memory_store_binding.pyandtest_members_dm_thread.py, and in a shuffled order (seed 22487).Proof: not provable -- other: the tests import the new member_memory_adopt module, so prove.py reverting every production hunk stops them at collection (exit 21 INCONCLUSIVE); the grant, label, check-in and redirected-store cases were checked red by hand with their fix hunks reverted
Manual verification
On an isolated gateway started from this branch (its own data home, loopback port, a scripted browser): created a bot, opened its thread, deleted it, opened New bot → Advanced settings, picked its memory, created, and opened the new bot; the server's answer named the kept store and member id, the offer list was then empty, and the thread opened under the new name. The refused pick, the storage failure and the failed list read were forced by answering those requests in the browser; the first-greeting turn was left out so no model ran.
Screenshots / video
Captured from this branch on an isolated loopback gateway (its own data home): a bot was created, its thread opened, the bot deleted, then New bot opened.
New bot → Advanced settings with a deleted bot's memory picked (dark, light):
A bot named in a non-Latin script is offered by the name it showed, not its config key:
The pick refused by the server (another bot took it first): nothing created, back to an empty memory:
Every other state (default, open list, storage failure, failed list read, delete text, the adopted bot)
Default, with the hint:
The list open:
Refused pick, light:
A storage failure on the same create is said as one, with its reason, and the pick stays:
The kept-memory list could not be read:
The danger-zone note and the delete confirmation:
The new bot after the adopt, on its Profile tab (its memory is its own private store, the kept one):
Related Issues
Closes #22487
Builds on #22947 by @mbriones98.
Sibling sweep
Swept:
git grep -n "provision_member_memory(" -- src/kiro_crew(every create path) andgit grep -n "del agents\[" -- src/kiro_crew(every delete path)Sibling: src/kiro_crew/cli_commands_agent.py -- changed here
Sibling: src/kiro_crew/dashboard/agent_admin/installed_agents.py -- changed here
Sibling: src/kiro_crew/crewmate_prune_migration.py -- not affected -- it deletes only fresh sync-shaped rows, which keep no member store
Sibling: src/kiro_crew/agent_materialization/first_crewmate.py -- not affected -- it makes the built-in first bot once, never from a user's pick
Sibling: src/kiro_crew/apps/builtins/auto_improvement/backend/crew.py -- not affected -- an app's own bot made from its manifest, never from a user's pick
Pattern harvest
Not generalizable: a member store is the one record a delete keeps on purpose while every reader needs a live owner, so the fix is a single re-own route, not a rule.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.