Repository navigation
fix(local): retain sandbox folders after incomplete teardown - #561
Conversation
|
🤖 Automated Claude routine — Env Pod PR Context Review. This is a bot, not Edgar Arakelyan; not a human review. Context from the sibling PR rather than from this diff: #555 (open, also answering #546) ships a documented, supported recipe for cleaning up a hard-killed run's local sandboxes, and it calls the method this PR changes. That recipe appears in for sandbox_id in local_sandbox_ids():
await LocalSandboxProvider().terminate_sandbox(sandbox_id)
remove_local_work_dir(sandbox_id)
Might be worth the two PRs agreeing on whether that documented loop should catch per id, and whether it should still call Generated by Claude Code |
…Docker With no Docker installed, nothing of a sandbox can have been started with it, so there's nothing to remove. With Docker unreachable, teardown now fails only for a sandbox whose folder records its own container, compose stack or closed network; one that ran only commands on this machine finishes with the old warning naming the cleanup command. The repeated stderr limit is named. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, this is the right direction: a teardown that couldn't confirm removal should keep the folder for a retry, and it makes #555's recipe exact. I pushed one change (9588e12, merged with The case: a local sandbox that never used Docker, such as the shipped
The change: teardown first asks Docker whether it's reachable (
Also: the repeated stderr limit is named ( Tests, on a Linux box:
One follow-up for #555's recipe: |
What and why
Local sandbox teardown can report success when Docker is unavailable or rejects container removal. The run then removes the sandbox work folder, losing the identity needed to retry. This complements #555 and addresses the teardown failure reported in #546.
Check the sandbox's named container and labeled containers and networks, report failed queries or removals, and report marked Linux processes that survive termination. Still attempt the other cleanup stages, including Compose, before returning an error. Existing run teardown retains the work folder and reports the sandbox as still up when termination fails. Image removal remains best effort because images can be shared.
With no Docker installed, nothing of a sandbox can have been started with it, so teardown finishes. With Docker unreachable, teardown fails only for a sandbox whose folder records its own container, compose stack or closed network; one that ran only commands on this machine finishes with a warning naming the cleanup command. Process discovery on macOS remains limited:
/proc-based host-process cleanup is Linux-only.How it was tested
.venv/bin/ruff check .passed.run_bundleSIGKILL integration run and real Linux-host process cleanup were not run. The existing macOS host-process limitation is unchanged.

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues remain.Summary
Local teardown now reports failed Docker queries and removals, plus Linux processes that survive termination. Existing teardown callers keep the sandbox folder when termination fails.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Stop marked processes] --> B[Check Docker] B -->|Reachable| C[Attempt container, Compose and labeled cleanup] B -->|Unreachable with recorded objects| D[Record failure] B -->|Missing, or unreachable without recorded objects| E[Finish Docker checks] C --> F{Any cleanup failures?} D --> F E --> F F -->|Yes| G[Raise error and retain folder] F -->|No| H[Caller removes folder]Reviews (5) · Last reviewed commit: "fix(local): a sandbox that made no Docke..." · Reviewed by Greptile