E2B ACP
Run Agent Client Protocol (ACP) agents such as goose, OpenCode or Claude Code inside an E2B sandbox, and drive them from your code with the official ACP client.
Source: packages/acp-python
Install
pip install e2b e2b-acp agent-client-protocol
Set E2B_API_KEY to your E2B API key, and the provider key the agent needs.
Usage
Create a sandbox from a template with the agent installed, then start the agent and connect your ACP client to it. The ACP Python SDK is asynchronous, so use AsyncSandbox.
import asyncio
import os
import acp
from acp import schema
from e2b import AsyncSandbox
from e2b_acp import AsyncACPAgent
class Client:
async def request_permission(self, session_id, tool_call, options, **kwargs):
allow = next((o for o in options if o.kind == "allow_once"), options[0])
return schema.RequestPermissionResponse(
outcome=schema.AllowedOutcome(outcome="selected", option_id=allow.option_id)
)
async def session_update(self, session_id, update, **kwargs):
if isinstance(update, schema.AgentMessageChunk) and update.content.type == "text":
print(update.content.text, end="")
async def main():
sandbox = await AsyncSandbox.create("goose", timeout=600)
try:
agent = AsyncACPAgent(
sandbox,
"goose acp --with-builtin developer",
Client(),
envs={
"GOOSE_PROVIDER": "openai",
"GOOSE_MODEL": "gpt-5.6-luna",
"OPENAI_API_KEY": os.environ["OPENAI_API_KEY"],
},
)
await agent.start()
await agent.connection.initialize(protocol_version=acp.PROTOCOL_VERSION)
session = await agent.connection.new_session(cwd="/home/user", mcp_servers=[])
await agent.connection.prompt(
session_id=session.session_id,
prompt=[acp.text_block("Create fizzbuzz.py for 1 to 15 and run it.")],
)
await agent.stop()
finally:
await sandbox.kill()
asyncio.run(main())
Where the agent's tools run
The agent talks ACP over its stdin and stdout. AsyncACPAgent turns off the client filesystem and terminal capabilities in initialize and answers agent requests for fs/* or terminal/* with an error, so the agent edits files and runs commands with its own tools inside the sandbox. It does not restrict the agent's network access or the MCP servers you pass to it.
Lifecycle
AsyncACPAgent(...)only stores the arguments;await agent.start()starts the agent and connects the client.start()can be called once.agent.stop()sends EOF to the agent and kills it if it has not exited withintimeout(5 seconds by default) of the call. Messages the agent sends after that are not delivered. Beforestart()it does nothing, so it is safe in afinallyblock. Whilestart()is still running,stop()andkill()wait for it and then stop the agent; the stop timeout counts from when the start finishes.agent.wait()returns the exit code once the agent exits. It raisesACPExceptionif the agent sent a message overmax_message_bytes.- If the agent exits, pending requests on the connection fail with a connection error. Use
agent.wait()for the exit code and passon_stderrto receive the agent's logs. - The agent runs as long as the sandbox does, so set the sandbox timeout for the longest task you expect.
Metadata
Release files for e2b-acp 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| e2b_acp-0.1.1.tar.gz | 13.5 kB | Without provenance | Details for e2b_acp-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| e2b_acp-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for e2b_acp-0.1.1-py3-none-any.whl |
Total release size: 29.1 kB
Release files / e2b_acp-0.1.1.tar.gz
| Download URL | e2b_acp-0.1.1.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bf42d6ba3312ceafd6fc72a9983c6ad15eacd5c095531f13c98c6f330a62eb9
|
|
BLAKE2b-256 checksum How to use checksums |
7302005eb9f765acfbb738533a1ff371af517fa285012f7bbceae5bd7fcb929a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / e2b_acp-0.1.1-py3-none-any.whl
| Download URL | e2b_acp-0.1.1-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89d713295a4f27755b11fd7804cac9db942acbd81c905b08d266ef7c0aeef569
|
|
BLAKE2b-256 checksum How to use checksums |
586c5244afe560a75e710338346a81fc5f02d40836d235e165151d9b0cce94bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for e2b-acp 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.