GitHub Copilot in a Docker Sandbox
This setup runs the GitHub Copilot CLI inside a Docker Sandbox (sbx) microVM, with its own filesystem and a default-deny network policy. A Band SDK process on the host receives room messages and drives Copilot over ACP with sbx exec -i <sandbox> copilot --acp. Use it when Copilot should edit a workspace without host access or a GitHub token inside the VM.
This is a source example in the Band Python SDK repository (examples/acp/copilot_sandbox/), not a published kit. It is specific to the Copilot CLI. For the adapter itself, see GitHub Copilot CLI. To run a Python agent entirely inside a sandbox, see Docker Sandbox (sbx) Kit.
How It Works
- The host process holds the live Band connection, loads the agent from
agent_config.yaml, and starts onesbx exec -iprocess per room. - Dockerβs host-side proxy injects the GitHub token and the Band agent API key on outbound requests. The VM sees only placeholders.
- The adapterβs own Band tool server listens on the host loopback, which the sandbox cannot reach, so the example sets
inject_band_tools=False. - The included
band-mcp-kitmixin runsband-mcpon the sandbox loopback instead, andclient.pypasses its URL to Copilot as the MCP serverband. As ofband-sdk5.0.0, Copilot can reply only through Band tools, soclient.pyrefuses to start withoutBAND_MCP_SSE_URL.
Both paths must use the same Band agent. If band-mcp holds a different agentβs key, room tools return 404.
Prerequisites
- Docker Desktop and Docker Sandboxes (
sbx). The mixin validates withsbxv0.43.0. - Python 3.11 or later,
uv,git, andgh - A GitHub account with Copilot access, signed in with
gh auth login
Set Up the Sandbox
Create Your Agent in Band
-
In the Band web app, open Agents in the sidebar and click Connect remote agent.
-
Enter an Agent name and a Description of at least 10 characters, then click Connect Agent.
-
In the Agent Created Successfully! dialog, copy the ID and the API Key. The dialog shows the API key only once.
-
In the repository root, create
agent_config.yamlunder the keycopilot_acp_agent, whichclient.pyloads:agent_config.yaml
Install Docker Sandboxes
sbx policy init balanced sets a default-deny global policy that allows common development, GitHub, and model API hosts. Skip it if sbx policy ls already lists a policy.
Store Host-Side Credentials
Store the Copilot token and the same Band agent API key you saved in agent_config.yaml:
The real keys stay in Dockerβs host-side secret store. Inside the sandbox, BAND_AGENT_KEY is the literal proxy-managed, which the proxy replaces on requests to app.band.ai.
Create the Sandbox with the Mixin
Choose the directory Copilot may access. sbx mounts it at the same absolute path inside the sandbox.
sbx kit validate prints VALID and a warning that caps is deprecated. The warning is expected.
Start the Host Bridge
The log shows Driving Copilot in sandbox 'copilot-band' over stdio (sbx exec -i)... and Copilot will call Band tools at http://127.0.0.1:3000/sse. Keep the process running. Without BAND_MCP_SSE_URL, client.py exits with a ValidationError for band_mcp_sse_url before it connects.
client.py passes BAND_MCP_SSE_URL to Copilot in its ACP session. Copilot resolves it inside the sandbox, where 127.0.0.1:3000 is band-mcp. The variables can also come from examples/acp/copilot_sandbox/.env, copied from .env.example.
Test from Band
In Band, add the agent to a room from Participants with Add participants, and @mention it with a coding task. Copilot runs the turn inside the sandbox and works in $SBX_WORKSPACE/<room_id>.
Adapter Configuration
client.py builds this configuration:
- Use
sbx exec -i, notsbx run.sbx runallocates a PTY and adds--yolo. cwdis the workspace root, and each room gets the subdirectory<cwd>/<room_id>. The host creates it, and the direct mount makes the same path exist in the sandbox.band-mcptakes an explicitchat_idargument on chat and message tools, unlike the adapterβs built-in tools.
What the Mixin Adds
band-mcp-kit/spec.yaml is a schema v1 mixin:
- Adds
app.band.ai,pypi.org, andfiles.pythonhosted.orgto the sandboxβs network allow list. - Installs
band-mcpwithuv tool install band-mcp, which installs the latest release on PyPI, and starts it with--transport sse --host 127.0.0.1 --port 3000. - Sets
ALLOWED_HOSTS='["localhost:*","127.0.0.1:*"]',BAND_BASE_URL=https://app.band.ai, andBAND_AGENT_KEY=proxy-managed.
band-mcp has no client authentication. Keep it on 127.0.0.1. The mixin targets Band Cloud; for another deployment, change BAND_BASE_URL, the allow list, and the --host of sbx secret set-custom.
Rules the mixin adds are part of the effective policy, not a full list of reachable hosts. The base policy and organization settings can add or remove access. Kit changes apply only when the sandbox is created: to change the mixin, remove and recreate the sandbox.