Skip to main content

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 within timeout (5 seconds by default) of the call. Messages the agent sends after that are not delivered. Before start() it does nothing, so it is safe in a finally block. While start() is still running, stop() and kill() 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 raises ACPException if the agent sent a message over max_message_bytes.
  • If the agent exits, pending requests on the connection fail with a connection error. Use agent.wait() for the exit code and pass on_stderr to 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.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for e2b-acp 0.1.3
File Size Uploaded Provenance Actions
e2b_acp-0.1.3.tar.gz 13.5 kB Without provenance Details for e2b_acp-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for e2b-acp 0.1.3
File Interpreter ABI Platform Actions
e2b_acp-0.1.3-py3-none-any.whl Python 3 none any Details for e2b_acp-0.1.3-py3-none-any.whl

Total release size: 29.1 kB

Release files / e2b_acp-0.1.3.tar.gz

Download URL e2b_acp-0.1.3.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
78f88e8d3991a0665b687e1d11984600f193c574d3b97efa1ad310100434d236
BLAKE2b-256 checksum
How to use checksums
c0845ab2e7488b4876b50d4e2f2ca2ec4ec499ecac23681faa324745f5d83306
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.3-py3-none-any.whl

Download URL e2b_acp-0.1.3-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2dbd9047c717fbfe10f61864aa83e94c3f20e53b3d8263301f4f25c5d3a744a4
BLAKE2b-256 checksum
How to use checksums
09564fefc8f9a8e52135ca92516906331792874bf81c24c4296fb3903b819e0a
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.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page