Repository navigation
Description
Found while fixing #1664 — deliberately left out of that PR to keep the P0 data-loss fix tight.
Summary
Rename keeps the agent's Docker volumes under the pre-rename base (agent-{old}-workspace); the live container carries the mount forward, so the running agent is fine. But three code paths still derive the volume name by f-stringing the agent's current name, which for a renamed agent points at a volume that does not exist:
services/agent_service/lifecycle.py::recreate_missing_container(bug(recovery): soft-delete recovery dead-ends —recovertells you tostart, butstart404s when the container is gone #1559 soft-delete recovery) —base_volumes = {f"agent-{agent_name}-workspace": ...}. Recovering a renamed, soft-deleted agent creates a fresh empty volume and starts the agent on it. The real data volume survives on disk (untouched, and bug: #1581 orphan-volume sweep can destroy a live renamed agent's home volume (rename keeps old volume name+label) #1664 keeps the sweep off it), but the agent comes back with an empty/home/developer— silently.services/agent_service/lifecycle.py::_read_template_yaml_from_volume(bug(recovery): soft-delete recovery dead-ends —recovertells you tostart, butstart404s when the container is gone #1559) — readstemplate.yamlfromagent-{agent_name}-workspace; for a renamed agent that volume is absent, so it falls back to defaults ({}) instead of the committed template metadata (agent-type / runtime).services/agent_service/deploy.py::_prepopulate_workspace_from_templateuses the same convention (fine today — deploy names are fresh — but it is the same latent assumption).
Fix
#1664 added the primitive: agent_ownership.volume_base_name (NULL ⇒ agent_name) + db.get_volume_base_name(agent). The purge path and the orphan sweep already resolve through it. These paths should too:
base = db.get_volume_base_name(agent_name) or agent_name
base_volumes = {f"agent-{base}-workspace": {"bind": "/home/developer", "mode": "rw"}}A repo-wide grep for f"agent-{...}-workspace" is the audit — every site that means "this agent's volume" must go through get_volume_base_name, never the current name.
Repro
- Create agent
old, write files to its workspace. - Rename
old→new. - Soft-delete
new, then recover it viaPOST /api/admin/soft-deleted/agents/new/recover. POST /api/agents/new/start→ container comes up on a brand-new emptyagent-new-workspace; the data sits unreferenced inagent-old-workspace.
Related
- bug: #1581 orphan-volume sweep can destroy a live renamed agent's home volume (rename keeps old volume name+label) #1664 (the P0: the sweep destroying that same volume) — added
volume_base_name+get_volume_base_name - bug(recovery): soft-delete recovery dead-ends —
recovertells you tostart, butstart404s when the container is gone #1559 (soft-delete recovery gap / recreate_missing_container) - Agent runtime data volumes: declared data paths with snapshot/restore and portable export #1169 (durable agent home volumes /
data_paths) — the data class at stake
Activity
dolho commentedon Jul 17, 2026
PR #1668 (stacked on #1666 — it needs that PR's
db.get_volume_base_nameprimitive).Reproduced exactly as filed, and the mechanism is worse than "creates a fresh volume":
containers.runcreates a missing named volume rather than failing, so recovery rebuilt the agent on an empty/home/developerand started it — the agent comes back looking healthy, just empty.All three sites this issue named are fixed and verified mock-free (real DB + real daemon): recovery now mounts the real data; the template read recovers the committed
researcher/codexinstead of silently falling back to defaults; and the deadagent_volume_nameassignment inrecreate_container_with_updated_configis gone — it named the wrong volume convincingly enough to read as the mount in use, which is how this class spreads.deploy.pyis correct by construction (fresh name, no row, no rename in its past) and is annotated as audited rather than changed.Two things worth flagging beyond the issue:
get_public_volume_name/get_shared_volume_namealso name off the live agent name, andrecreate_container_with_updated_configdrops the old public/shared mounts and re-adds them by current name — so rename + any recreate silently empties a renamed agent's publish dir and shared-out folder. Filed as bug: rename + recreate silently empties an agent's public/shared volumes (they name off the live agent name) #1669 rather than bundled, because it is not a mechanical swap: agents already renamed in the field have been writing toagent-{new}-public, so resolving to the pinned base would orphan that data instead. It needs an adopt/migrate decision.recovertells you tostart, butstart404s when the container is gone #1559 recreate test mocks the wholedatabasemodule, and an unstubbed MagicMock attribute is truthy — it would be f-stringed straight into the volume name. Stubbed explicitly.dolho commentedon Jul 17, 2026
Retargeted: this is now fixed in #1666 (was #1668, folded in).
The two PRs shared a root cause and a primitive, and this one could not merge before #1666 regardless — meanwhile a stacked PR gets no CI test net on this repo (
backend-unit-test.ymlonly triggers for PRs targetingdev/main), so the split cost coverage and bought nothing. Same commit, no rewrite; #1666 now carries both and runs the full base-vs-head suite on every push.fix(volumes): rename-safe volume identity — sweep, purge, create and …
feat(agents): editable display label with an immutable slug (ent#181) (…