Skip to content

bug: renamed agent's soft-delete recovery mounts a fresh empty workspace volume (rename keeps the old volume) #1665

Closed

Description

@dolho

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:

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

  1. Create agent old, write files to its workspace.
  2. Rename old → new.
  3. Soft-delete new, then recover it via POST /api/admin/soft-deleted/agents/new/recover.
  4. POST /api/agents/new/start → container comes up on a brand-new empty agent-new-workspace; the data sits unreferenced in agent-old-workspace.

Related

Activity

  1. added
    priority-p1
    type-bug
    theme-infrastructure
    status-in-progress
    on Jul 17, 2026
  2. self-assigned this
    on Jul 17, 2026
  3. dolho commented on Jul 17, 2026

    @dolho
    ContributorAuthor

    PR #1668 (stacked on #1666 — it needs that PR's db.get_volume_base_name primitive).

    Reproduced exactly as filed, and the mechanism is worse than "creates a fresh volume": containers.run creates a missing named volume rather than failing, so recovery rebuilt the agent on an empty /home/developer and started it — the agent comes back looking healthy, just empty.

    recovery mounts today : agent-r1665-new-workspace
       -> agent sees      : <volume does not exist -> docker CREATES it empty>
    resolved via #1664 pin: agent-r1665-old-workspace
       -> agent sees      : the agents real data
    

    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/codex instead of silently falling back to defaults; and the dead agent_volume_name assignment in recreate_container_with_updated_config is gone — it named the wrong volume convincingly enough to read as the mount in use, which is how this class spreads. deploy.py is 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:

  4. added
    status-in-dev
    and removed
    status-in-progress
    on Jul 17, 2026
  5. dolho commented on Jul 17, 2026

    @dolho
    ContributorAuthor

    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.yml only triggers for PRs targeting dev/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.

  6. removed
    status-in-dev
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority-p1theme-infrastructuretype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions