Skip to content

fix(sandbox): don't duplicate agent file and --config-dir args#2487

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/docker-agent-cli-misinterpreting-sandbox-8bfa43f8
Apr 21, 2026
Merged

fix(sandbox): don't duplicate agent file and --config-dir args#2487
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/docker-agent-cli-misinterpreting-sandbox-8bfa43f8

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented Apr 21, 2026

Problem

docker agent run --sandbox ./pokemon.yaml

runs the right agent but sends ./pokemon.yaml as the first chat message.

Root cause

In cmd/root/sandbox.go, runInSandbox appends args and --config-dir a second time on top of what the dockerAgentArgs helper already produces. Inside the sandbox, the duplicated agent file path is then interpreted by docker-agent run as the first user message (args[1]).

Fix

Drop the duplicate append calls in runInSandbox and rely on the helper's output as-is.

Tests

Adds cmd/root/sandbox_test.go covering:

  • Agent file and --config-dir appear exactly once.
  • Agent file precedes --config-dir (so cobra parses it as the agent, not a message).
  • --sandbox / --sbx flags are stripped (no sandbox recursion).
  • --yolo is added by default but not duplicated when the user passes it.

runInSandbox was appending args and --config-dir a second time on top of what the dockerAgentArgs helper already produces. Inside the sandbox, the duplicated agent file path was then interpreted by `docker-agent run` as the first user message, e.g. `docker agent run --sandbox ./pokemon.yaml` would send "./pokemon.yaml" as the initial prompt.

Add regression tests covering argument de-duplication, ordering, flag stripping (--sandbox/--sbx), and the implicit --yolo default.

Assisted-By: docker-agent
@dgageot dgageot requested a review from a team as a code owner April 21, 2026 14:24
@dgageot dgageot merged commit 77abf88 into docker:main Apr 21, 2026
9 checks passed
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.

2 participants