Expand description
Startup reconciliation between the two host-global agent trees:
shared/agents/registry/ (one record per named agent instance) and
shared/agents/definitions/ (one record per agent definition).
The picker’s “My Agents” list is built from the instance registry
(listrecentsessions reads Registry::list_active), with each row’s
display fields — name, provider, model vendor, agent type — resolved
from the definition it points at. An active instance record whose
definition has been tombstoned therefore renders as a row nothing can
fill in: no provider means no icon, and the name falls back to
"(missing definition)". Clicking it can only fail. The user sees a
delete that half-worked — the icon vanished, the card stayed.
Deletion now sweeps every registry record belonging to the agent
(Registry::hard_delete_for_agent), so no new orphan is created.
This pass exists for the ones already on disk, from every build that
deleted an agent before that fix: the two trees are host-global and
shared across channels, so those records outlive any one install and
nothing else would ever remove them.
Deliberately narrow: a record is only dropped when its definition is
provably deleted — absent from the active definition tree AND
present in that tree’s retired/ tombstones. “Not in the global
definition store” alone is not enough, because a definition can
legitimately live only in some channel’s local SQLite (e.g. it was
created while the global store couldn’t be opened), and dropping those
would delete real agents rather than ghosts.
Functions§
- prune_
tombstoned_ instance_ records - Drop active instance records whose definition is tombstoned. Returns the number of files removed. Best-effort: a tree that can’t be read is logged and skipped, never fatal.