Reference
Agents
claude_code
Claude Code agent.
Agent that uses Claude Code running in a sandbox.
The agent can either use a version of Claude Code installed in the sandbox, or can download a version and install it in the sandbox (see docs on version option below for details).
Use disallowed_tools to control access to tools. See Tools available to Claude for the list of built-in tools which can be disallowed.
Use the attempts option to enable additional submissions if the initial submission(s) are incorrect (by default, no additional attempts are permitted).
@agent
def claude_code(
name: str = "Claude Code",
description: str = dedent("""
Autonomous coding agent capable of writing, testing, debugging,
and iterating on code across multiple languages.
"""),
system_prompt: str | None = None,
skills: Sequence[str | Path | Skill] | None = None,
mcp_servers: Sequence[MCPServerConfig] | None = None,
bridged_tools: Sequence[BridgedToolsSpec] | None = None,
disallowed_tools: list[str] | None = None,
centaur: bool | CentaurOptions = False,
attempts: int | AgentAttempts = 1,
model: str | None = None,
model_config: str | None = None,
model_aliases: dict[str, str | Model] | None = None,
opus_model: str | None = None,
sonnet_model: str | None = None,
haiku_model: str | None = None,
subagent_model: str | None = None,
filter: GenerateFilter | None = None,
auto_mode: bool = False,
retry_refusals: int | None = 3,
retry_uncaught_errors: int | None = 3,
cwd: str | None = None,
env: dict[str, str] | None = None,
user: str | None = None,
sandbox: str | None = None,
version: Literal["auto", "sandbox", "stable", "latest"] | str = "auto",
debug: bool | None = None,
) -> Agentnamestr-
Agent name (used in multi-agent systems with
as_tool()andhandoff()) descriptionstr-
Agent description (used in multi-agent systems with
as_tool()andhandoff()) system_promptstr | None-
Additional system prompt to append to default system prompt.
skillsSequence[str | Path | Skill] | None-
Additional skills to make available to the agent.
mcp_serversSequence[MCPServerConfig] | None-
MCP servers to make available to the agent.
bridged_toolsSequence[BridgedToolsSpec] | None-
Host-side Inspect tools to expose to the agent via MCP. Each BridgedToolsSpec creates an MCP server that makes the specified tools available to the agent running in the sandbox.
disallowed_toolslist[str] | None-
List of tool names to disallow entirely.
centaurbool | CentaurOptions-
Run in ‘centaur’ mode, which makes Claude Code available to an Inspect
human_cli()agent rather than running it unattended. attemptsint | AgentAttempts-
Configure agent to make multiple attempts. When this is specified, the task will be scored when the agent stops calling tools. If the scoring is successful, execution will stop. Otherwise, the agent will be prompted to pick up where it left off for another attempt.
modelstr | None-
Model name to use for Opus and Sonnet calls (defaults to main model for task).
model_configstr | None-
Model id used to select the identity Claude Code presents to itself (its “You are powered by the model …” system prompt) and any model-gated client behavior. Defaults to
None, which derives it from the real served model so the presented identity matches what’s actually running. Purely the displayed identity — calls are still bridged to the served Inspect model regardless. (Claude Code renders the genuine name/cutoff for recognized Anthropic ids and shows other ids verbatim.) model_aliasesdict[str, str | Model] | None-
Optional mapping of model names to Model instances or model name strings. Allows using custom Model implementations (e.g., wrapped Agents) instead of standard models. When a model name in the mapping is referenced, the corresponding Model/string is used.
opus_modelstr | None-
The model to use for
opus, or foropusplanwhen Plan Mode is active. Defaults tomodel. sonnet_modelstr | None-
The model to use for
sonnet, or foropusplanwhen Plan Mode is not active. Defaults tomodel. haiku_modelstr | None-
The model to use for haiku, or background functionality. Defaults to
model. subagent_modelstr | None-
The model to use for subagents. Defaults to
model. filterGenerateFilter | None-
Filter for intercepting bridged model requests.
auto_modebool-
Use
autopermission mode rather than--dangerously-skip-permissions. Note that this can result in rejected tool calls so only enable if your evaluation can tolerate this. retry_refusalsint | None-
Should refusals be retried? Defaults to retrying up to 3 times.
retry_uncaught_errorsint | None-
Should uncaught errors (unexpected crashes of Claude Code) be retried. Defaults to retrying up to 3 times.
cwdstr | None-
Working directory to run claude code within.
envdict[str, str] | None-
Environment variables to set for claude code.
userstr | None-
User to execute claude code with.
sandboxstr | None-
Optional sandbox environment name.
versionLiteral['auto', 'sandbox', 'stable', 'latest'] | str-
Version of claude code to use. One of: - “auto”: Use any available version of claude code in the sandbox, otherwise download the current stable version. - “sandbox”: Use the version of claude code in the sandbox (raises
RuntimeErrorif claude is not available in the sandbox) - “stable”: Download and use the current stable version of claude code. - “latest”: Download and use the very latest version of claude code. - “x.x.x”: Download and use a specific version of claude code. debugbool | None-
Add
--debugcli flag and trace all debug output.
codex_cli
Codex CLI.
Agent that uses OpenAI Codex CLI running in a sandbox.
Use the attempts option to enable additional submissions if the initial submission(s) are incorrect (by default, no additional attempts are permitted).
def codex_cli(
name: str = ...,
description: str = ...,
system_prompt: str | None = ...,
model_config: str | None = ...,
skills: Sequence[str | Path | Skill] | None = ...,
mcp_servers: Sequence[MCPServerConfig] | None = ...,
bridged_tools: Sequence[BridgedToolsSpec] | None = ...,
web_search: CodexWebSearch = ...,
goals: bool = ...,
centaur: bool | CentaurOptions = ...,
attempts: int | AgentAttempts = ...,
model: str | None = ...,
model_aliases: dict[str, str | Model] | None = ...,
filter: GenerateFilter | None = ...,
retry_refusals: int | None = ...,
home_dir: str | None = ...,
cwd: str | None = ...,
env: dict[str, str] | None = ...,
user: str | None = ...,
sandbox: str | None = ...,
version: Literal['auto', 'sandbox', 'latest'] | str = ...,
config_overrides: dict[str, str] | None = ...,
debug: bool | None = ...,
*,
disallowed_tools: list[Literal['web_search']] | None = ...,
) -> Agentnamestr-
Agent name (used in multi-agent systems with
as_tool()andhandoff()) descriptionstr-
Agent description (used in multi-agent systems with
as_tool()andhandoff()) system_promptstr | None-
Additional system prompt to append to default system prompt.
model_configstr | None-
Codex model slug used to select the system prompt and tool set. Defaults to
None, which derives the slug from the real model so Codex’s prompt/tooling aligns with what’s actually running. Pass an explicit slug to override. skillsSequence[str | Path | Skill] | None-
Additional skills to make available to the agent.
mcp_serversSequence[MCPServerConfig] | None-
MCP servers to make available to the agent.
bridged_toolsSequence[BridgedToolsSpec] | None-
Host-side Inspect tools to expose to the agent via MCP. Each BridgedToolsSpec creates an MCP server that makes the specified tools available to the agent running in the sandbox.
web_searchCodexWebSearch-
Web search mode. Use “live” for live web search, “cached” for cached web search, or “disabled” to disable web search. Defaults to “live”.
goalsbool-
Enable Codex goal tools (defaults to
True). centaurbool | CentaurOptions-
Run in ‘centaur’ mode, which makes Codex CLI available to an Inspect
human_cli()agent rather than running it unattended. attemptsint | AgentAttempts-
Configure agent to make multiple attempts. When this is specified, the task will be scored when the agent stops calling tools. If the scoring is successful, execution will stop. Otherwise, the agent will be prompted to pick up where it left off for another attempt.
modelstr | None-
Model name to use (defaults to main model for task).
model_aliasesdict[str, str | Model] | None-
Optional mapping of model names to Model instances or model name strings. Allows using custom Model implementations (e.g., wrapped Agents) instead of standard models. When a model name in the mapping is referenced, the corresponding Model/string is used.
filterGenerateFilter | None-
Filter for intercepting bridged model requests.
retry_refusalsint | None-
Should refusals be retried? (pass number of times to retry)
home_dirstr | None-
Home directory to use for codex cli. If set, AGENTS.md, skills, and the MCP configuration will be written here.
cwdstr | None-
Working directory to run codex cli within.
envdict[str, str] | None-
Environment variables to set for codex cli
userstr | None-
User to execute codex cli with.
sandboxstr | None-
Optional sandbox environment name.
versionLiteral['auto', 'sandbox', 'latest'] | str-
Version of codex cli to use. One of: - “auto”: Use any available version of codex cli in the sandbox, otherwise download the latest version. - “sandbox”: Use the version of codex cli in the sandbox (raises
RuntimeErrorif codex is not available in the sandbox) - “latest”: Download and use the very latest version of codex cli. - “x.x.x”: Download and use a specific version of codex cli. config_overridesdict[str, str] | None-
Additional Codex CLI configuration overrides. Each key-value pair is passed as
-c key=valueto the CLI. debugbool | None-
Trace all debug output.
disallowed_toolslist[Literal['web_search']] | None
gemini_cli
Gemini CLI agent.
Agent that uses Google Gemini CLI running in a sandbox with Inspect model bridging.
Use the attempts option to enable additional submissions if the initial submission(s) are incorrect (by default, no additional attempts are permitted).
@agent
def gemini_cli(
name: str = "Gemini CLI",
description: str = dedent("""
Autonomous coding agent capable of writing, testing, debugging,
and iterating on code across multiple languages.
"""),
system_prompt: str | None = None,
skills: Sequence[str | Path | Skill] | None = None,
mcp_servers: Sequence[MCPServerConfig] | None = None,
bridged_tools: Sequence[BridgedToolsSpec] | None = None,
centaur: bool | CentaurOptions = False,
attempts: int | AgentAttempts = 1,
model: str | None = None,
model_aliases: dict[str, str | Model] | None = None,
gemini_model: str = "gemini-2.5-pro",
filter: GenerateFilter | None = None,
retry_refusals: int | None = None,
cwd: str | None = None,
env: dict[str, str] | None = None,
user: str | None = None,
sandbox: str | None = None,
version: Literal["auto", "sandbox", "stable", "latest"] | str = "auto",
debug: bool | None = None,
) -> Agentnamestr-
Agent name (used in multi-agent systems with
as_tool()andhandoff()) descriptionstr-
Agent description
system_promptstr | None-
Additional system prompt to append
skillsSequence[str | Path | Skill] | None-
Additional skills to make available to the agent.
mcp_serversSequence[MCPServerConfig] | None-
MCP servers to make available to the agent
bridged_toolsSequence[BridgedToolsSpec] | None-
Host-side Inspect tools to expose to the agent via MCP
centaurbool | CentaurOptions-
Run in ‘centaur’ mode, which makes Gemini CLI available to an Inspect
human_cli()agent rather than running it unattended. attemptsint | AgentAttempts-
Configure agent to make multiple attempts
modelstr | None-
Model name to use for inspect bridge (defaults to main model for task)
model_aliasesdict[str, str | Model] | None-
Optional mapping of model names to Model instances or model name strings. Allows using custom Model implementations (e.g., wrapped Agents) instead of standard models. When a model name in the mapping is referenced, the corresponding Model/string is used.
gemini_modelstr-
Gemini model name to pass to CLI. This bypasses the auto-router. Use “gemini-2.5-pro” (default) or “gemini-2.5-flash”. The actual model calls still go through the inspect bridge, but this disables the router.
filterGenerateFilter | None-
Filter for intercepting bridged model requests
retry_refusalsint | None-
Should refusals be retried? (pass number of times to retry)
cwdstr | None-
Working directory to run gemini cli within
envdict[str, str] | None-
Environment variables to set for gemini cli
userstr | None-
User to execute gemini cli with
sandboxstr | None-
Optional sandbox environment name
versionLiteral['auto', 'sandbox', 'stable', 'latest'] | str-
Version of gemini cli to use. One of: - “auto”: Use any available version in sandbox, otherwise download latest - “sandbox”: Use sandbox version (raises RuntimeError if not available) - “stable”/“latest”: Download and use the latest version - “x.x.x”: Download and use a specific version
debugbool | None-
Trace all debug output.
opencode
OpenCode agent.
Agent that uses OpenCode running in a sandbox with Inspect model bridging.
Use the attempts option to enable additional submissions if the initial submission(s) are incorrect (by default, no additional attempts are permitted).
@agent
def opencode(
name: str = "OpenCode",
description: str = dedent("""
Open-source autonomous coding agent for the terminal, capable
of writing, testing, debugging, and iterating on code across
multiple languages.
"""),
system_prompt: str | None = None,
skills: Sequence[str | Path | Skill] | None = None,
mcp_servers: Sequence[MCPServerConfig] | None = None,
bridged_tools: Sequence[BridgedToolsSpec] | None = None,
centaur: bool | CentaurOptions = False,
attempts: int | AgentAttempts = 1,
model: str | None = None,
model_aliases: dict[str, str | Model] | None = None,
opencode_model: str = "anthropic/claude-sonnet-4-5",
filter: GenerateFilter | None = None,
retry_refusals: int | None = None,
cwd: str | None = None,
env: dict[str, str] | None = None,
user: str | None = None,
sandbox: str | None = None,
version: Literal["auto", "sandbox", "stable", "latest"] | str = "auto",
debug: bool | None = None,
) -> Agentnamestr-
Agent name (used in multi-agent systems with
as_tool()andhandoff()) descriptionstr-
Agent description
system_promptstr | None-
Additional system prompt to append
skillsSequence[str | Path | Skill] | None-
Additional skills to make available to the agent.
mcp_serversSequence[MCPServerConfig] | None-
MCP servers to make available to the agent
bridged_toolsSequence[BridgedToolsSpec] | None-
Host-side Inspect tools to expose to the agent via MCP
centaurbool | CentaurOptions-
Run in ‘centaur’ mode, which makes OpenCode available to an Inspect
human_cli()agent rather than running it unattended. attemptsint | AgentAttempts-
Configure agent to make multiple attempts
modelstr | None-
Model name to use for inspect bridge (defaults to main model for task)
model_aliasesdict[str, str | Model] | None-
Optional mapping of model names to Model instances or model name strings. Allows using custom Model implementations (e.g., wrapped Agents) instead of standard models. When a model name in the mapping is referenced, the corresponding Model/string is used.
opencode_modelstr-
OpenCode model identifier to pass to the CLI in the form
provider/model(default:"anthropic/claude-sonnet-4-5"). The actual model calls still go through the Inspect bridge; this just selects which provider client OpenCode uses to format the request. filterGenerateFilter | None-
Filter for intercepting bridged model requests
retry_refusalsint | None-
Should refusals be retried? (pass number of times to retry)
cwdstr | None-
Working directory to run opencode within
envdict[str, str] | None-
Environment variables to set for opencode
userstr | None-
User to execute opencode with
sandboxstr | None-
Optional sandbox environment name
versionLiteral['auto', 'sandbox', 'stable', 'latest'] | str-
Version of opencode to use. One of: - “auto”: Use any available version in sandbox, otherwise download latest - “sandbox”: Use sandbox version (raises RuntimeError if not available) - “stable”/“latest”: Download and use the latest version - “x.x.x”: Download and use a specific version
debugbool | None-
Trace all debug output.
mini_swe_agent
mini-swe-agent agent.
Agent that uses mini-swe-agent running in a sandbox. Mini-swe-agent is a minimal 100-line agent that solves GitHub issues using only bash commands.
The agent can either use a version of mini-swe-agent installed in the sandbox, or can download and install it via pip (see docs on version option below).
Use attempts to enable additional submissions if initial submission(s) are incorrect (by default, no additional attempts are permitted).
This agent does not handle compaction natively. Use compaction to specify a compaction strategy.
@agent
def mini_swe_agent(
name: str = "mini-swe-agent",
description: str = dedent("""
Minimal AI agent that solves software engineering tasks using bash commands.
100 lines of Python, radically simple, scores >74% on SWE-bench verified.
"""),
system_prompt: str | None = None,
centaur: bool | CentaurOptions = False,
attempts: int | AgentAttempts = 1,
model: str | None = None,
model_aliases: dict[str, str | Model] | None = None,
filter: GenerateFilter | None = None,
retry_refusals: int | None = None,
compaction: CompactionStrategy | None = None,
cwd: str | None = None,
env: dict[str, str] | None = None,
user: str | None = None,
sandbox: str | None = None,
version: Literal["stable", "sandbox", "latest"] | str = "stable",
debug: bool | None = None,
) -> Agentnamestr-
Agent name (used in multi-agent systems with
as_tool()andhandoff()) descriptionstr-
Agent description (used in multi-agent systems)
system_promptstr | None-
Additional system prompt to include (appended to any system messages from the task).
centaurbool | CentaurOptions-
Run in ‘centaur’ mode, which makes mini-swe-agent available to an Inspect
human_cli()agent rather than running it unattended. attemptsint | AgentAttempts-
Configure agent to make multiple attempts.
modelstr | None-
Model name to use (defaults to main model for task).
model_aliasesdict[str, str | Model] | None-
Optional mapping of model names to Model instances or model name strings. Allows using custom Model implementations (e.g., wrapped Agents) instead of standard models. When a model name in the mapping is referenced, the corresponding Model/string is used.
filterGenerateFilter | None-
Filter for intercepting bridged model requests.
retry_refusalsint | None-
Should refusals be retried? (pass number of times to retry)
compactionCompactionStrategy | None-
Compaction strategy for managing context window overflow.
cwdstr | None-
Working directory to run mini-swe-agent within.
envdict[str, str] | None-
Environment variables to set for mini-swe-agent.
userstr | None-
User to execute mini-swe-agent with.
sandboxstr | None-
Optional sandbox environment name.
versionLiteral['stable', 'sandbox', 'latest'] | str-
Version of mini-swe-agent to use. One of: - “stable”: Download and install the default pinned version. - “sandbox”: Use version in sandbox (raises RuntimeError if not available) - “latest”: Download and install latest version from PyPI. - “x.x.x”: Install and use a specific version.
debugbool | None-
Trace all debug output.
Binaries
download_agent_binary
Download agent binary.
Download an agent binary. This version will be added to the cache of downloaded versions (which retains the 5 most recently downloaded versions).
Use this if you need to ensure that a specific version of an agent binary is downloaded in advance (e.g. if you are going to run your evaluations offline). After downloading, explicit requests for the downloaded version (e.g. claude_code(version="1.0.98")) will not require network access.
def download_agent_binary(
binary: Literal["claude_code", "codex_cli"],
version: Literal["stable", "latest"] | str,
platform: SandboxPlatform,
) -> NonebinaryLiteral['claude_code', 'codex_cli']-
Type of binary to download
versionLiteral['stable', 'latest'] | str-
Version to download (“stable”, “latest”, or an explicit version number).
platformSandboxPlatform-
Target platform (“linux-x64”, “linux-arm64”, “linux-x64-musl”, or “linux-arm64-musl”)
cached_agent_binaries
List the agent binaries which have been cached on this system.
def cached_agent_binaries(
binary: Literal["claude_code", "codex_cli"] | None = None, quiet: bool = False
) -> AgentBinariesbinaryLiteral['claude_code', 'codex_cli'] | None-
Type of binary to list (lists all of if not specified).
quietbool-
Do not print the binaries as a side effect
download_wheels_tarball
Download all wheels for a package and its dependencies.
Downloads wheels from PyPI for the specified platform and Python version, then bundles them into a tarball for offline installation in sandbox. Downloaded wheels are cached locally (retaining 5 most recent versions).
def download_wheels_tarball(
package_name: str,
version: str | None,
platform: SandboxPlatform,
python_version: str,
) -> tuple[bytes, str]package_namestr-
PyPI package name (e.g., “mini-swe-agent”)
versionstr | None-
Package version or None for latest
platformSandboxPlatform-
Target sandbox platform
python_versionstr-
Python version without dots (e.g., “312”)
AgentBinary
Agent binary.
class AgentBinary(NamedTuple)Attributes
agentLiteral['claude_code', 'codex_cli']-
Agent type.
versionstr-
Agent version.
pathPath-
“Agent path.
SandboxPlatform
Target platform identifier for sandbox binary and wheel downloads.
SandboxPlatform: TypeAlias = Literal[
"linux-x64", "linux-arm64", "linux-x64-musl", "linux-arm64-musl"
]ACP
interactive_claude_code
Claude Code agent via ACP.
Uses the claude-agent-acp adapter in a sandbox. Supports multi-turn sessions and mid-turn interrupts.
def interactive_claude_code(
*,
disallowed_tools: list[str] | None = ...,
skills: list[str | Path | Skill] | None = ...,
opus_model: str | Model | None = ...,
sonnet_model: str | Model | None = ...,
haiku_model: str | Model | None = ...,
subagent_model: str | Model | None = ...,
model: str | Model | None = ...,
filter: GenerateFilter | None = ...,
bridged_tools: list[BridgedToolsSpec] | None = ...,
mcp_servers: list[MCPServerConfig] | None = ...,
system_prompt: str | None = ...,
retry_refusals: int | None = ...,
model_map: dict[str, str | Model] | None = ...,
cwd: str | None = ...,
env: dict[str, str] | None = ...,
user: str | None = ...,
sandbox: str | None = ...,
) -> ACPAgentdisallowed_toolslist[str] | None-
Tool names to disallow.
skillslist[str | Path | Skill] | None-
Additional skills to make available.
opus_modelstr | Model | None-
Model for opus calls.
sonnet_modelstr | Model | None-
Model for sonnet calls.
haiku_modelstr | Model | None-
Model for haiku / background calls.
subagent_modelstr | Model | None-
Model for subagents.
modelstr | Model | NonefilterGenerateFilter | Nonebridged_toolslist[BridgedToolsSpec] | Nonemcp_serverslist[MCPServerConfig] | Nonesystem_promptstr | Noneretry_refusalsint | Nonemodel_mapdict[str, str | Model] | Nonecwdstr | Noneenvdict[str, str] | Noneuserstr | Nonesandboxstr | None
interactive_codex_cli
Codex CLI agent via ACP.
Uses the codex-acp adapter in a sandbox. Supports multi-turn sessions and mid-turn interrupts.
def interactive_codex_cli(
*,
web_search: CodexWebSearch = ...,
goals: bool = ...,
skills: list[str | Path | Skill] | None = ...,
home_dir: str | None = ...,
config_overrides: dict[str, str] | None = ...,
disallowed_tools: list[Literal['web_search']] | None = ...,
) -> ACPAgentweb_searchCodexWebSearch-
Web search mode. Use
"live"for live web search,"cached"for cached web search, or"disabled"to disable web search. goalsbool-
Enable Codex goal tools.
skillslist[str | Path | Skill] | None-
Additional skills to make available.
home_dirstr | None-
Override for
CODEX_HOMEdirectory in the sandbox. config_overridesdict[str, str] | None-
Extra Codex config.toml key-value pairs.
disallowed_toolslist[Literal['web_search']] | None
interactive_gemini_cli
Gemini CLI agent via ACP.
Uses gemini’s native --experimental-acp flag in a sandbox. Supports multi-turn sessions and mid-turn interrupts.
def interactive_gemini_cli(
*,
skills: list[str | Path | Skill] | None = ...,
version: Literal['auto', 'sandbox', 'stable', 'latest'] | str = ...,
debug: bool = ...,
model: str | Model | None = ...,
filter: GenerateFilter | None = ...,
bridged_tools: list[BridgedToolsSpec] | None = ...,
mcp_servers: list[MCPServerConfig] | None = ...,
system_prompt: str | None = ...,
retry_refusals: int | None = ...,
model_map: dict[str, str | Model] | None = ...,
cwd: str | None = ...,
env: dict[str, str] | None = ...,
user: str | None = ...,
sandbox: str | None = ...,
) -> ACPAgentskillslist[str | Path | Skill] | None-
Additional skills to make available.
versionLiteral['auto', 'sandbox', 'stable', 'latest'] | str-
Version of gemini CLI to use. One of:
"auto","sandbox","stable","latest", or a specific semver version string. debugbool-
Run gemini-cli with
--debugandGEMINI_DEBUG_LOG_FILEset to$HOME/gemini-debug.login the sandbox (in ACP mode console output is patched away from stderr, so the log file is the only way to surface internals). modelstr | Model | NonefilterGenerateFilter | Nonebridged_toolslist[BridgedToolsSpec] | Nonemcp_serverslist[MCPServerConfig] | Nonesystem_promptstr | Noneretry_refusalsint | Nonemodel_mapdict[str, str | Model] | Nonecwdstr | Noneenvdict[str, str] | Noneuserstr | Nonesandboxstr | None
bridge_mcp_to_acp
Convert bridge MCPServerConfigHTTP objects to ACP HttpMcpServer.
def bridge_mcp_to_acp(configs: list[MCPServerConfigHTTP]) -> list[HttpMcpServer]configslist[MCPServerConfigHTTP]
ACPAgent
Base class for ACP-based agents running in sandboxes.
Manages the ACP lifecycle (connection, session, MCP announcement, cleanup). Subclasses implement :meth:_start_agent for agent-specific setup.
Sets up the ACP lifecycle, exposes .conn and .session_id, signals .ready, then blocks until the task is cancelled. The caller drives all prompts via conn.prompt() / conn.cancel().
class ACPAgent(Agent)ACPAgentParams
Keyword arguments accepted by :class:ACPAgent.
class ACPAgentParams(TypedDict, total=False)acp_connection
Bridge an ExecRemoteProcess to ACP. Yield (conn, feeder, error_info).
Bridges ExecRemoteProcess to the SDK’s connect_to_agent() via a transport wrapper, then cleans up on exit.
feeder is a background task that reads process stdout and feeds it into the ACP reader. It completes when the process exits, so callers can await feeder to detect unexpected process termination.
proc_info collects stderr output and the exit code as the process runs. Inspect after await feeder for full diagnostics.
Usage::
async with acp_connection(proc) as (conn, feeder, proc_info):
await conn.initialize(...)
session = await conn.new_session(...)
await conn.prompt(...)
@contextlib.asynccontextmanager
async def acp_connection(
proc: ExecRemoteProcess,
) -> AsyncIterator[tuple[ClientSideConnection, asyncio.Task[None], ErrorInfo]]procExecRemoteProcess