Skip to content

fix(runtime): label docker sandbox containers with the run id for teardown - #933

Merged
0xallam merged 2 commits into
mainfrom
devin/1785337149-inner-sandbox-run-label
Jul 29, 2026
Merged

fix(runtime): label docker sandbox containers with the run id for teardown#933
0xallam merged 2 commits into
mainfrom
devin/1785337149-inner-sandbox-run-label

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

The docker runtime backend never labeled the sandbox container with the run's correlation id, so an external control plane could not find and stop it by run id — an abrupt teardown of the parent process (cancel / relaunch / restart) left the container orphaned and running. The managed backends already stamp this metadata on their sandboxes (which is why they tear down cleanly); this brings the docker backend to parity.

Stamp the label on container create from the environment (no-op when unset), factored into a small helper alongside the existing _apply_sandbox_network / _apply_resource_limits / _apply_log_limits:

def _apply_run_labels(create_kwargs: dict[str, Any]) -> None:
    run_id = os.getenv("STRIX_RUN_ID")
    if not run_id:
        return
    labels = create_kwargs.setdefault("labels", {})
    if not isinstance(labels, dict):
        return
    labels["strix-run-id"] = run_id
    run_type = os.getenv("STRIX_RUN_TYPE")
    if run_type:
        labels["strix-run-type"] = run_type

A caller can then docker listContainers(filters={label: ["strix-run-id=<id>"]}) and stop the sandbox as part of tearing the run down. Behavior is unchanged when STRIX_RUN_ID is not set in the environment.

Link to Devin session: https://app.devin.ai/sessions/54414ea3ecb34ade9189534e5c690969
Requested by: @0xallam

…rdown

The managed backends stamp each sandbox with the run's correlation id so an
external control plane can find and stop it by run id. The docker backend did
not, so an abrupt teardown of the parent process (cancel / relaunch / restart)
left the container orphaned and running. Stamp strix-run-id (and strix-run-type
when set) from the environment on container create; no-op when STRIX_RUN_ID is
unset.
@0xallam 0xallam self-assigned this Jul 29, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds Docker sandbox container labels derived from STRIX_RUN_ID and optional STRIX_RUN_TYPE environment variables so external teardown can locate containers by run correlation ID.

  • Preserves existing container labels when represented as a dictionary.
  • Leaves container creation unchanged when STRIX_RUN_ID is unset.
  • Applies the labels immediately before creating the Docker container.

Confidence Score: 5/5

The PR appears safe to merge with no concrete defects identified in the changed container-labeling path.

The helper preserves dictionary-based labels, adds run metadata only when configured, and passes the resulting creation arguments through the existing Docker container creation flow.

Important Files Changed

Filename Overview
strix/runtime/docker_client.py Adds and invokes a focused helper that safely stamps environment-provided run metadata onto Docker container creation arguments without changing unset-environment behavior.

Reviews (1): Last reviewed commit: "fix(runtime): label docker sandbox conta..." | Re-trigger Greptile

@0xallam
0xallam merged commit 1a2fa89 into main Jul 29, 2026
@0xallam
0xallam deleted the devin/1785337149-inner-sandbox-run-label branch July 29, 2026 15:05
@usestrix usestrix deleted a comment from 5hy7xz92nd-oss Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant