Skip to content

fix(sandbox): forward --deny/--usd/--tokens/--api-base into the container - #168

Merged
vedaant00 merged 3 commits into
vedaant00:mainfrom
t957095:fix/sandbox-policy-flags
Sep 21, 2026
Merged

vedaant00 merged 3 commits into
vedaant00:mainfrom
t957095:fix/sandbox-policy-flags

Conversation

@t957095

@t957095 t957095 commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Problem

The --sandbox branch in cli.py returned before any policy was built, and the container ran opendot -p ... --yes with no other flags: a --deny pattern the user explicitly hard-blocked became auto-approved inside the sandbox, and --usd, --tokens, --api-base were silently dropped.

Fix

build_run_command and run_sandboxed now accept deny, usd, tokens, and api_base and append them to the container argv; cli.py forwards them from args. Isolation semantics unchanged (still --network none by default, scoped env forwarding).

Tests: two regression tests (flags present when set, absent when unset) — both pass.

Note: a few existing sandbox tests fail on Windows on clean main (commit-back path handling, e.g. C\keep.txt); pre-existing and unrelated.

Closes #163

…iner

The --sandbox path returned before any policy was built, and the
container ran with a bare --yes: a user hard-blocked --deny pattern
was auto-approved inside the sandbox, and --usd/--tokens/--api-base
were silently dropped. build_run_command and run_sandboxed now accept
and forward them, and cli.py passes them through.

Tests: two regression tests (flags forwarded when set, omitted when
unset). Note: several existing sandbox tests fail on Windows on clean
main too ('C\keep.txt' path handling in commit-back); pre-existing
and unrelated.

Closes vedaant00#163

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Add CLI wiring coverage and address incompatible local API endpoints with disabled or isolated networking.

Review effort: Lite
Findings: None

What changed in this PR

Forwards sandbox policy, budget, and API-base options into containerized runs.

Changes:

  • Added forwarding for --deny, --usd, --tokens, and --api-base.
  • Updated CLI-to-sandbox wiring.
  • Added regression tests for set and unset flags.
File Description
tests/​test_sandbox.py Tests forwarded and omitted flags.
src/​opendot/​sandbox.py Appends options to container arguments.
src/​opendot/​cli.py Passes parsed options into sandbox execution.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

CI lint job runs ruff format --check; the new call sites were not
formatted (magic trailing comma style). No behaviour change.
@t957095

t957095 commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the failing CI / lint check: the two files this PR touches were not ruff format-clean (magic trailing comma style at the new build_run_command call sites). Ran ruff format on src/opendot/sandbox.py and tests/test_sandbox.py — no behaviour change.

Verified locally with the exact CI commands: ruff check src/ tests/ and ruff format --check src/ tests/ both pass, and the two policy-flag regression tests still pass.

…tainer

Address the review note on vedaant00#168. Forwarding --api-base is correct, but the
flag names a server the *container* has to reach, and two common cases now
fail obscurely instead of loudly:

- with the default --network none the container has no network at all;
- a loopback URL resolves to the container itself, not the host.

Both now print an actionable warning before the run. This matters more than
it looks because --api-base defaults to $OPENAI_API_BASE, so anyone with
that exported picks it up on every --sandbox run without typing the flag.

Isolation semantics are unchanged; this only adds a diagnostic.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vedaant00

Copy link
Copy Markdown
Owner

Good fix @t957095, the flag forwarding is exactly right and I like that the argv is unchanged when nothing is set. Verified locally: repeated --deny survives, budgets forward, and the new test fails on pre-fix code.

I pushed one follow-up for the review note about --api-base. Forwarding it is correct, but it names a server the container has to reach, and two cases still failed obscurely: the default --network none leaves no network at all, and a loopback URL means the container itself rather than your host. Both now warn with a suggested fix. This matters more than it looks because --api-base defaults to $OPENAI_API_BASE, so anyone with that exported picks it up on every sandbox run without typing the flag.

@vedaant00
vedaant00 merged commit 1978f53 into vedaant00:main Sep 21, 2026
4 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.

--sandbox silently drops --deny, --usd, --tokens and --api-base

3 participants