Repository navigation
Add bbox run-image ephemeral one-shot command - #207
Merged
Merged
Conversation
Implements #205: `bbox run-image IMAGE [flags] -- CMD` boots an arbitrary OCI image once, without editing config or registering an agent. Builds an in-memory agent.Agent from flags via the existing config.AgentFromOverride path (#200) and runs it through the normal SandboxRunner — no config-file mutation, no registry persistence. Ephemeral defaults (safer-than-custom): credential persistence off, settings import off, env forwarding empty, MCP off, git token / SSH agent forwarding off. Egress defaults to permissive with a stderr disclosure so the bare example boots; tighten with --egress-profile/--allow-host. --mcp forces mcp.mode=env and inherits the safe-tools custom-agent authz default. Reuses run() by extracting a shared runSandbox(...) tail. The in-memory agent is registered data-only (nil Plugin) so isCustomAgent/applyCustomAgentAuthzDefault apply the safe-tools default. Name derives from the image repo basename when --name is unset. docs/run-image.md documents the minimum image contract (shell at /bin/sh, command on PATH, CA bundle, sandbox user UID 1000) and the ephemeral defaults.
jhrozek
reviewed
Jun 30, 2026
jhrozek
left a comment
Contributor
There was a problem hiding this comment.
Two findings from review (one HIGH egress bug, one MEDIUM MCP UX issue). The rest of the PR looks solid — clean runSandbox extraction, DDD boundaries respected, and strong table-driven tests.
Fold --allow-host into the run-image agent override so the ValidateCustomAgent gate sees hosts for a non-permissive egress profile. Previously --allow-host flowed only into RunOpts.AllowHosts (applied at VM start), so the load-time validation rejected --egress-profile standard/locked unless --mcp was also set, breaking the documented example. Hosts are parsed via egress.ParseHostFlag and filed under override.EgressHosts[profile]; runFlags.allowHosts is cleared to avoid filing them twice. Warn when MCP sub-flags (--mcp-authz-profile, --mcp-group, --mcp-port, --mcp-config, --mcp-session-ttl) are set without --mcp, which is off by default for run-image. They were silently dropped, misleading the operator into thinking they tightened tool access. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #205 —
bbox run-image IMAGE [flags] -- CMD, an ephemeral one-shot that boots an arbitrary OCI image in a sandbox VM, runs the command, forwards only explicitly-requested env, and persists nothing. No config-file mutation, no registry persistence.bbox run-image ghcr.io/me/aider-bbox:latest -- aider --model gpt-5 bbox run-image ghcr.io/me/aider-bbox:latest \ --name aider --env OPENAI_API_KEY --env 'AIDER_*' \ --memory 4g --cpus 4 --mcp --mcp-authz-profile safe-tools \ --egress-profile standard --allow-host api.openai.com:443 -- aiderBuilds an in-memory
agent.Agentfrom flags via the existingconfig.AgentFromOverridepath (#200) and runs it through the normalSandboxRunner.Ephemeral defaults (safer-than-custom)
--env(repeatable;--env-forwardalias)--mcp(forcesmcp.mode=env; inheritssafe-toolsauthz default)--git-token--git-ssh-agentpermissive(with stderr disclosure)--egress-profile standard --allow-host ...Snapshot isolation, review, egress/MCP tighten-only semantics all still apply. Universal
BBOX_*env vars are injected as for any agent.How it works
run-image(cmd/bbox/run_image.go). The first positional is the image; everything after--is the command.run()by extracting a sharedrunSandbox(...)tail (cmd/bbox/main.go);run()keeps its front-end,runRunImage()builds the in-memory agent then calls the same tail.registry.Add— same seamregisterCustomAgentsuses — soisCustomAgent/applyCustomAgentAuthzDefaultapply thesafe-toolsMCP authz default. Nothing is written to disk.--nameis unset; validated viaagent.ValidateName.buildRunImageOverrideandderiveAgentNameare table-tested;validateMCPFlagsextracted to de-duplicate front-end validation.Minimum image contract
Documented in
docs/run-image.md: the image provides the Linux rootfs; the agent command must be onPATHinside the image;/bin/shand a CA bundle at/etc/ssl/certsare expected; sandbox user UID 1000 //home/sandbox.bbox-initis embedded by the VM runtime (PID 1), not the image.Verification
task fmt— cleantask lint— 0 issuestask test(race) — all green, incl. newcmd/bboxtestsderiveAgentName,buildRunImageOverride(defaults/env/mcp/authz/egress/resources/copy-semantics),ValidateCustomAgentaccept/reject, cobra arg parsing (IMG -- CMD, missing--, empty command), RunE pre-IO errors (--seed-credentialsrejection, invalid image ref with lowercase hint, invalid--name), name-collision guard (built-in + custom + derived),--namewins-over-derivation,--env/--env-forwardalias merge,validateMCPFlags, and thecfg.Agentsmap-detach (no aliasing into global config).Review-panel driven changes
A spec + standards + domain (security/arch/UX/DevEx/duplication/QA) panel reviewed the diff; this commit applies the cross-confirmed findings: git-token/SSH-agent off-by-default (contradicts the issue's "forwards only explicitly requested env"),
--seed-credentialsrejected as incompatible, name-collision guard covers custom agents (not just built-ins), deadnameparam dropped, derived agent name surfaced on stderr, MCP validation de-duplicated,cfg.Agentsmap-aliasing fixed, image-contract discoverable from--help, image-ref error hints lowercase refs.Notes / out of scope
runSandboxstill hard-codesinfravm.NewMicroVMRunner(no VMRunner injection). A full Prepare-boundary E2E test isn't reachable without that refactor; RunE-level tests stop at the pre-runSandboxboundary (guard, flag parsing, pure helpers). Left for a follow-up.Closes #205.