Skip to main content

Reference

Public API for inspect_swe.

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 tools to restrict Claude Code to a fixed set of built-in tools, and disallowed_tools to deny individual tools. See Tools available to Claude for the list of built-in tools.

Use the attempts option to enable additional submissions if the initial submission(s) are incorrect (by default, no additional attempts are permitted).

def claude_code(
    name: str = ...,
    description: str = ...,
    system_prompt: str | None = ...,
    skills: Sequence[str | Path | Skill] | None = ...,
    mcp_servers: Sequence[MCPServerConfig] | None = ...,
    bridged_tools: Sequence[Tool | BridgedToolsSpec] | None = ...,
    mcp_ready_timeout: float = ...,
    disallowed_tools: list[str] | None = ...,
    centaur: bool | CentaurOptions = ...,
    attempts: int | AgentAttempts = ...,
    model: str | None = ...,
    model_config: str | None = ...,
    effort: ClaudeCodeEffort | None = ...,
    model_aliases: dict[str, str | Model] | None = ...,
    transparent_proxy: bool = ...,
    opus_model: str | None = ...,
    sonnet_model: str | None = ...,
    haiku_model: str | None = ...,
    subagent_model: str | None = ...,
    filter: GenerateFilter | None = ...,
    permission_mode: ClaudeCodePermissionMode | None = ...,
    retry_refusals: int | None = ...,
    retry_uncaught_errors: int | None = ...,
    cwd: str | None = ...,
    env: dict[str, str] | None = ...,
    user: str | None = ...,
    sandbox: str | None = ...,
    version: Literal['auto', 'sandbox', 'stable', 'latest'] | str = ...,
    debug: bool | None = ...,
    replace_system_prompt: str | None = ...,
    allowlist_mcp_tools: bool = ...,
    allowlist_bridged_tools: bool = ...,
    tools: list[str] | None = ...,
    strict_mcp_config: bool = ...,
    *,
    auto_mode: bool = ...,
) -> Agent
name str

Agent name (used in multi-agent systems with as_tool() and handoff())

description str

Agent description (used in multi-agent systems with as_tool() and handoff())

system_prompt str | None

Additional instructions to append to Claude Code’s built-in system prompt.

skills Sequence[str | Path | Skill] | None

Additional skills to make available to the agent.

mcp_servers Sequence[MCPServerConfig] | None

MCP servers to make available to the agent.

bridged_tools Sequence[Tool | 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. Plain Tools are grouped into one MCP server named tools.

mcp_ready_timeout float

Seconds to wait for bridged MCP endpoints to serve tools before the agent launch errors.

disallowed_tools list[str] | None

List of tool names to disallow entirely (disallowing "WebSearch" also disables web search for the agent).

centaur bool | CentaurOptions

Run in ‘centaur’ mode, which makes Claude Code available to an Inspect human_cli() agent rather than running it unattended.

attempts int | 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.

model str | None

Model name to use for Opus and Sonnet calls (defaults to main model for task).

model_config str | 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.)

effort ClaudeCodeEffort | None

Reasoning effort for the served model. Sets GenerateConfig.reasoning_effort on the model backing this agent (see resolve_claude_code_models), not a Claude Code CLI flag: the bridge drops request-level generation config from the inner agent by default, so passing this through the CLI would have no effect on the model actually serving the request. None leaves the model’s own default effort in place.

model_aliases dict[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.

transparent_proxy bool

Forward the client’s generation parameters as authoritative instead of merging in the eval’s active GenerateConfig (defaults to False). Claude Code’s auto-mode security classifier makes its own internal model call under permission_mode="auto", and by default the classifier’s own generation parameters (e.g. max_tokens) are dropped in favor of the eval’s GenerateConfig. The classifier’s model identity is unaffected either way – it already resolves through the presented-identity/role aliases above (or the fallback model, for any identity not covered by those), the same as every other bridged request.

opus_model str | None

The model to use for opus, or for opusplan when Plan Mode is active. Defaults to model.

sonnet_model str | None

The model to use for sonnet, or for opusplan when Plan Mode is not active. Defaults to model.

haiku_model str | None

The model to use for haiku, or background functionality. Defaults to model.

subagent_model str | None

The model to use for subagents. Defaults to model.

filter GenerateFilter | None

Filter for intercepting bridged model requests.

permission_mode ClaudeCodePermissionMode | None

Claude Code --permission-mode. The complete CLI set is "acceptEdits", "auto", "bypassPermissions", "default", "dontAsk", and "plan". "bypassPermissions" is near-equivalent to the default --dangerously-skip-permissions path, and "dontAsk" is also now reachable. --allowed-tools is consulted in every mode except "bypassPermissions". In unattended runs, tools excluded from --allowed-tools cannot be prompted for and are denied; "auto" is the only mode where otherwise-unapproved calls are adjudicated by Claude Code’s first-party classifier rather than denied unconditionally.

retry_refusals int | None

Should refusals be retried? Defaults to retrying up to 3 times.

retry_uncaught_errors int | None

Should uncaught errors (unexpected crashes of Claude Code) be retried. Defaults to retrying up to 3 times.

cwd str | None

Working directory to run claude code within.

env dict[str, str] | None

Environment variables to set for claude code. Applied last, so they override the sandbox defaults inspect_swe sets (see _claude_code/env.py); e.g. CLAUDE_CODE_DISABLE_AUTO_MEMORY="0" re-enables auto-memory.

user str | None

User to execute claude code with. Inside a sandbox identity scope (such as inspect_swarm’s users isolation), claude code runs as the scope’s user, in the scope’s working directory unless cwd is set, and centaur mode raises an error.

sandbox str | None

Optional sandbox environment name.

version Literal['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 RuntimeError if 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. Inside a sandbox identity scope, “auto” downloads a verified copy rather than using one found in the sandbox, and “sandbox” raises an error.

debug bool | None

Add --debug cli flag and trace all debug output.

replace_system_prompt str | None

System prompt that replaces Claude Code’s built-in system prompt. Cannot be combined with system_prompt.

allowlist_mcp_tools bool

Whether to add static caller-provided MCP tools to --allowed-tools (default True). It matters in every permission mode except "bypassPermissions": in unattended runs, excluded static tools are denied without prompting. Set False with permission_mode="auto" when Claude Code’s first-party classifier should adjudicate those tools. Bridged Inspect tools are governed separately by allowlist_bridged_tools.

allowlist_bridged_tools bool

Whether to add bridged Inspect tools to --allowed-tools (default True, preserving the behavior every existing caller gets). Bridged tools are allowlisted by default because an evaluation may depend on them being callable, and in every mode except "auto" a tool left off --allowed-tools is denied without prompting in an unattended run.

Set False ONLY with permission_mode="auto", where an excluded tool is adjudicated by the classifier rather than denied. This is required for an evaluation that measures Claude Code’s own auto-mode classifier acting on bridged tools: an allow rule resolves at step 1 of the permission flow, BEFORE the classifier, so an allowlisted bridged call is never reviewed. Left True under "auto", a run whose entire tool surface is bridged produces ZERO adjudications and looks clean while being wholly unreviewed.

tools list[str] | None

Built-in tools to make available (Claude Code --tools). None keeps Claude Code’s default tool set, a list restricts the session to those tools, and [] removes every built-in tool so that only MCP tools (e.g. bridged_tools) remain. Leaving "WebSearch" out of the list also disables web search.

strict_mcp_config bool

Only use the MCP servers passed via mcp_servers and bridged_tools (Claude Code --strict-mcp-config), ignoring any other MCP configuration present in the sandbox.

auto_mode bool

codex_cli

Codex CLI.

Agent that uses OpenAI Codex CLI running in a sandbox.

Image content in the input is written to files in the sandbox and attached to the prompt via codex exec --image (requires a codex version that supports the --image option).

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[Tool | BridgedToolsSpec] | None = ...,
    mcp_ready_timeout: float = ...,
    mcp_startup_timeout: int | None = ...,
    web_search: CodexWebSearch = ...,
    goals: bool = ...,
    auto_review: bool | CodexAutoReview = ...,
    centaur: bool | CentaurOptions = ...,
    attempts: int | AgentAttempts = ...,
    model: str | None = ...,
    model_aliases: dict[str, str | Model] | None = ...,
    transparent_proxy: bool = ...,
    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 = ...,
    sandbox_mode: CodexSandboxMode = ...,
    approval_policy: CodexApprovalPolicy = ...,
    network_access: bool = ...,
    approve_static_mcp_tools: bool = ...,
    *,
    disallowed_tools: list[Literal['web_search']] | None = ...,
) -> Agent
name str

Agent name (used in multi-agent systems with as_tool() and handoff())

description str

Agent description (used in multi-agent systems with as_tool() and handoff())

system_prompt str | None

Additional system prompt to append to default system prompt.

model_config str | 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. The slug comes from the model_catalog_json file in config_overrides when set (a plain absolute path in the sandbox, optionally quoted, with no escapes), else from the installed release’s catalog. Pass an explicit slug to override.

skills Sequence[str | Path | Skill] | None

Additional skills to make available to the agent.

mcp_servers Sequence[MCPServerConfig] | None

MCP servers to make available to the agent.

bridged_tools Sequence[Tool | 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. Plain Tools are grouped into one MCP server named tools. In Codex code mode (models whose catalog entry sets tool_mode = "code_mode_only") the model calls these tools from code it writes rather than proposing each call, so the agent raises before launch unless each spec sets require_proposal=False. The check is skipped when config_overrides sets features, model_catalog_json or profile keys.

mcp_ready_timeout float

Seconds to wait for bridged MCP endpoints to serve tools before the agent launch errors.

mcp_startup_timeout int | None

Seconds Codex waits for bridged MCP server startup. Defaults to 300; pass None to use Codex’s default.

web_search CodexWebSearch

Web search mode. Use “live” for live web search, “cached” for cached web search, or “disabled” to disable web search. Defaults to “live”.

goals bool

Enable Codex goal tools (defaults to True).

auto_review bool | CodexAutoReview

Enable Codex automated approval review (guardian). When enabled, Codex runs with its own sandbox active (workspace-write) and on-request approvals; escalation requests (e.g. writes outside the workspace) are adjudicated by a guardian model rather than auto-approved. The network_access setting still applies, since that effective mode is workspace-write. Pass CodexAutoReview to customize the guardian policy and model. Requires Codex CLI >= 0.137.0. Defaults to False.

centaur bool | CentaurOptions

Run in ‘centaur’ mode, which makes Codex CLI available to an Inspect human_cli() agent rather than running it unattended.

attempts int | 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.

model str | None

Model name to use (defaults to main model for task).

model_aliases dict[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.

transparent_proxy bool

Bind the auto_review guardian slug (codex-auto-review) to the real target model even when auto_review doesn’t configure its own model, and forward the client’s generation parameters as authoritative instead of merging in the eval’s active GenerateConfig (defaults to False). Codex hardcodes that guardian slug into every reviewer request regardless of configuration, so without this the request has no alias, falls through to the session model instead of the intended guardian, and the guardian’s own generation parameters (e.g. max_tokens) are dropped. Required for auto_review=True with approval_policy="on-request" when no explicit CodexAutoReview(model=...) is set. The ordinary bridged request (Codex’s own --model slug) is unaffected – it keeps resolving to the real target model exactly as it does with transparent_proxy=False.

filter GenerateFilter | None

Filter for intercepting bridged model requests.

retry_refusals int | None

Should refusals be retried? (pass number of times to retry)

home_dir str | None

Home directory to use for codex cli. If set, AGENTS.md, skills, and the MCP configuration will be written here. Inside a sandbox identity scope it must expand to an absolute path (such as ~/.codex); a relative one raises an error.

cwd str | None

Working directory to run codex cli within.

env dict[str, str] | None

Environment variables to set for codex cli

user str | None

User to execute codex cli with. Inside a sandbox identity scope (such as inspect_swarm’s users isolation), codex cli runs as the scope’s user, in the scope’s working directory unless cwd is set, and centaur mode raises an error.

sandbox str | None

Optional sandbox environment name.

version Literal['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 RuntimeError if 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. Inside a sandbox identity scope, “auto” downloads a verified copy rather than using one found in the sandbox, and “sandbox” raises an error.

config_overrides dict[str, str] | None

Additional Codex CLI configuration overrides. Each key-value pair is passed as -c key=value to the CLI, except approval_policy and sandbox_mode, which are intercepted and validated (invalid values raise ValueError) so that command construction and the bridged-MCP configuration are derived from one effective value rather than silently disagreeing with the raw flag.

debug bool | None

Trace all debug output.

sandbox_mode CodexSandboxMode

Codex’s own sandbox policy for model-generated shell commands (-s/--sandbox), not related to the sandbox option above that selects an Inspect sandbox environment. Defaults to "danger-full-access", which combined with approval_policy="never" (the default) reproduces the original --dangerously-bypass-approvals-and-sandbox behavior.

The restricted modes run Codex’s Linux sandbox, which on current codex releases requires a system bwrap (bubblewrap) binary in the sandbox image – the codex release archive ships only the codex binary, so no bundled fallback exists, and codex panics at shell launch without it (this agent fails fast with an actionable error instead). The container runtime must also permit unprivileged user namespace creation; Docker’s default seccomp profile does not. The mechanism is version-dependent: codex <= 0.77 used Landlock+seccomp (no bwrap), 0.98 had bwrap opt-in.

Mode semantics for model-generated commands (the Codex parent process contacts MCP servers and the model proxy outside this sandbox): "read-only" blocks writes AND network, and with the default approval_policy="never" denies writes outright with no approval path (the agent cannot edit anything). "workspace-write" makes cwd, /tmp and $TMPDIR writable, but remounts top-level .git (and .agents/.codex) in each writable root read-only – model-run git commit/checkout/stash fail (flip side: the agent cannot tamper with its own .codex CODEX_HOME).

approval_policy CodexApprovalPolicy

Codex’s approval policy (AskForApproval). Defaults to "never". Under headless codex exec (the default), codex itself overrides the runtime policy to never regardless of this setting (verified on codex 0.42.0 through 0.145.0), so a non-"never" value without an approvals reviewer raises ValueError here rather than silently breaking bridged tools. Prompting policies are effective in centaur mode, or headless with config_overrides={"approvals_reviewer": ...} (codex’s auto-review escape hatch).

network_access bool

Whether Codex’s "workspace-write" sandbox may access the network for model-generated commands. Defaults to True – note this inverts Codex’s own default (false) to preserve continuity with the previous unconditional full-access behavior; ignored by other sandbox modes. Applies under auto_review too, whose effective mode is workspace-write: at True the sandbox grants network up front, so the guardian has no network escalation to adjudicate. config_overrides={"sandbox_workspace_write.network_access": "false"} also wins over this setting (later -c pairs take precedence in codex).

approve_static_mcp_tools bool

Also pre-approve tool calls from static mcp_servers (not just Inspect-bridged servers) when the effective approval policy is "never". Defaults to False: static servers keep Codex’s per-server default gate. Note that under the restricted sandbox modes that default cancels un-annotated static tool calls headlessly (inspect’s MCPServerConfig cannot express default_tools_approval_mode), so set this to True if you combine sandbox_mode with static mcp_servers. Raises if combined with auto_review=True: that macro’s effective policy is "on-request", never "never", so the override this option applies would be silently unreachable.

disallowed_tools list[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[Tool | BridgedToolsSpec] | None = None,
    mcp_ready_timeout: float = DEFAULT_MCP_READY_TIMEOUT,
    web_search: bool = True,
    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,
) -> Agent
name str

Agent name (used in multi-agent systems with as_tool() and handoff())

description str

Agent description

system_prompt str | None

Additional system prompt to append

skills Sequence[str | Path | Skill] | None

Additional skills to make available to the agent.

mcp_servers Sequence[MCPServerConfig] | None

MCP servers to make available to the agent

bridged_tools Sequence[Tool | BridgedToolsSpec] | None

Host-side Inspect tools to expose to the agent via MCP. Each BridgedToolsSpec creates an MCP server; plain Tools are grouped into one MCP server named tools.

mcp_ready_timeout float

Seconds to wait for bridged MCP endpoints to serve tools before the agent launch errors.

web_search bool

Enable the agent’s web search tool (defaults to True).

centaur bool | CentaurOptions

Run in ‘centaur’ mode, which makes Gemini CLI available to an Inspect human_cli() agent rather than running it unattended.

attempts int | AgentAttempts

Configure agent to make multiple attempts

model str | None

Model name to use for inspect bridge (defaults to main model for task)

model_aliases dict[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_model str

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.

filter GenerateFilter | None

Filter for intercepting bridged model requests

retry_refusals int | None

Should refusals be retried? (pass number of times to retry)

cwd str | None

Working directory to run gemini cli within

env dict[str, str] | None

Environment variables to set for gemini cli

user str | None

User to execute gemini cli with

sandbox str | None

Optional sandbox environment name

version Literal['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 newest release that is at least 7 days old - “x.x.x”: Download and use a specific version

debug bool | 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[Tool | BridgedToolsSpec] | None = None,
    mcp_ready_timeout: float = DEFAULT_MCP_READY_TIMEOUT,
    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-6",
    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,
    session_title: str | None = "Inspect eval",
) -> Agent
name str

Agent name (used in multi-agent systems with as_tool() and handoff())

description str

Agent description

system_prompt str | None

Additional system prompt to append

skills Sequence[str | Path | Skill] | None

Additional skills to make available to the agent.

mcp_servers Sequence[MCPServerConfig] | None

MCP servers to make available to the agent

bridged_tools Sequence[Tool | BridgedToolsSpec] | None

Host-side Inspect tools to expose to the agent via MCP. Each BridgedToolsSpec creates an MCP server; plain Tools are grouped into one MCP server named tools.

mcp_ready_timeout float

Seconds to wait for bridged MCP endpoints to serve tools before the agent launch errors.

centaur bool | CentaurOptions

Run in ‘centaur’ mode, which makes OpenCode available to an Inspect human_cli() agent rather than running it unattended.

attempts int | AgentAttempts

Configure agent to make multiple attempts

model str | None

Model name to use for inspect bridge (defaults to main model for task)

model_aliases dict[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_model str

OpenCode model identifier to pass to the CLI in the form provider/model (default: "anthropic/claude-sonnet-4-6"). The actual model calls still go through the Inspect bridge; this just selects which provider client OpenCode uses to format the request.

filter GenerateFilter | None

Filter for intercepting bridged model requests

retry_refusals int | None

Should refusals be retried? (pass number of times to retry)

cwd str | None

Working directory to run opencode within

env dict[str, str] | None

Environment variables to set for opencode

user str | None

User to execute opencode with

sandbox str | None

Optional sandbox environment name

version Literal['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 The prompt is delivered on stdin, which needs opencode >= 1.14.42; earlier versions prepend a newline to piped input (only reachable with an older opencode pre-installed in the sandbox).

debug bool | None

Trace all debug output.

session_title str | None

Session title passed to opencode run --title. Any non-default title makes opencode skip its automatic title-generation model call – an extra bridged request per session whose result a headless run never uses – so the default fixed title suppresses that call. Pass None to restore opencode’s title generation. An empty string makes opencode use the first 50 characters of the prompt as the title (also without a model call).

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,
) -> Agent
name str

Agent name (used in multi-agent systems with as_tool() and handoff())

description str

Agent description (used in multi-agent systems)

system_prompt str | None

Additional system prompt to include (appended to any system messages from the task).

centaur bool | CentaurOptions

Run in ‘centaur’ mode, which makes mini-swe-agent available to an Inspect human_cli() agent rather than running it unattended.

attempts int | AgentAttempts

Configure agent to make multiple attempts.

model str | None

Model name to use (defaults to main model for task).

model_aliases dict[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.

filter GenerateFilter | None

Filter for intercepting bridged model requests.

retry_refusals int | None

Should refusals be retried? (pass number of times to retry)

compaction CompactionStrategy | None

Compaction strategy for managing context window overflow.

cwd str | None

Working directory to run mini-swe-agent within.

env dict[str, str] | None

Environment variables to set for mini-swe-agent.

user str | None

User to execute mini-swe-agent with.

sandbox str | None

Optional sandbox environment name.

version Literal['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.

debug bool | None

Trace all debug output.

antigravity

Google Antigravity SDK agent.

Runs Google’s Antigravity SDK (google-antigravity, which bundles the localharness engine) headless inside an Inspect sandbox, with model calls routed through the sandbox agent bridge. The SDK’s native connection speaks the Gemini generateContent wire directly to the bridge via a GeminiAPIEndpoint base_url override (no OpenAI translation), mirroring gemini_cli.

@agent
def antigravity(
    name: str = "Antigravity",
    description: str = "Sandboxed Google Antigravity SDK coding agent.",
    system_prompt: str | None = None,
    mcp_servers: Sequence[MCPServerConfig] | None = None,
    bridged_tools: Sequence[Tool | BridgedToolsSpec] | None = None,
    mcp_ready_timeout: float = DEFAULT_MCP_READY_TIMEOUT,
    model: str | None = None,
    model_aliases: dict[str, str | Model] | None = None,
    filter: _ModelGenerateFilter | None = None,
    retry_refusals: int | None = None,
    user: str | None = None,
    cwd: str | None = None,
    sandbox: str | None = None,
    version: str = "0.1.7",
    endpoint_model: str = _DEFAULT_ENDPOINT_MODEL,
    debug: bool | None = None,
) -> Agent
name str

Agent name.

description str

Agent description.

system_prompt str | None

Additional system prompt to append.

mcp_servers Sequence[MCPServerConfig] | None

MCP servers to make available to the agent (HTTP configs; localharness reaches servers over streamable HTTP).

bridged_tools Sequence[Tool | BridgedToolsSpec] | None

Host-side Inspect tools to expose to the agent via MCP. Each BridgedToolsSpec creates an MCP server; plain Tools are grouped into one MCP server named tools.

mcp_ready_timeout float

Seconds to wait for bridged MCP endpoints to serve tools before the agent launch errors.

model str | None

Model name to use for the inspect bridge (defaults to the task model).

model_aliases dict[str, str | Model] | None

Optional mapping of model names to Model instances/strings. Alias keys resolve against the client-sent model name, which for this agent is endpoint_model.

filter _ModelGenerateFilter | None

Filter for intercepting bridged model requests. Note this agent’s filter is typed Model-first (the non-deprecated GenerateFilter form); the deprecated str-first form is not accepted, unlike sibling agents, because the confinement wrapper invokes the user filter Model-first directly, with no legacy-dispatch branching of its own.

retry_refusals int | None

Should refusals be retried? (pass number of times to retry)

user str | None

Sandbox user to run the SDK as (defaults to the sandbox default user).

cwd str | None

Working directory for the SDK (defaults to the user’s home directory).

sandbox str | None

Optional sandbox environment name.

version str

Version of the google-antigravity SDK to provision when it is not already present in the sandbox image.

endpoint_model str

Model name the SDK client presents to the bridge endpoint.

debug bool | None

Trace the full runner 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", "kimi_code", "opencode"],
    version: Literal["stable", "latest"] | str,
    platform: SandboxPlatform,
) -> None
binary Literal['claude_code', 'codex_cli', 'kimi_code', 'opencode']

Type of binary to download

version Literal['stable', 'latest'] | str

Version to download (“stable”, “latest”, or an explicit version number).

platform SandboxPlatform

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", "kimi_code", "opencode"] | None = None,
    quiet: bool = False,
) -> AgentBinaries
binary Literal['claude_code', 'codex_cli', 'kimi_code', 'opencode'] | None

Type of binary to list (lists all of if not specified).

quiet bool

Do not print the binaries as a side effect

resolve_agent_version

Resolve the version of an agent binary that would be installed.

Resolves “stable” or “latest” to the concrete version agent would install in this process (an explicit version number is returned unchanged). Use this to pin a version once at setup time so every sample in a run installs the same binary and the run records which version actually ran.

def resolve_agent_version(
    agent: Literal["claude_code", "codex_cli", "kimi_code", "opencode"],
    version: Literal["stable", "latest"] | str,
    platform: SandboxPlatform = "linux-x64",
) -> str
agent Literal['claude_code', 'codex_cli', 'kimi_code', 'opencode']

Agent whose version to resolve.

version Literal['stable', 'latest'] | str

Version to resolve. “stable” and “latest” are resolved against the agent’s release manifest. Any other value is returned unchanged: an explicit version number is already concrete, and “auto” / “sandbox” refer to whatever is installed in the sandbox and cannot be resolved on the host, so they pass through for the agent function to handle at install time.

platform SandboxPlatform

Target platform (“linux-x64”, “linux-arm64”, “linux-x64-musl”, or “linux-arm64-musl”). The version string is the same on every platform, but resolution (and its per-process cache) is per platform and consults that platform’s release manifest, which may not exist for every platform.

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_name str

PyPI package name (e.g., “mini-swe-agent”)

version str | None

Package version or None for latest

platform SandboxPlatform

Target sandbox platform

python_version str

Python version without dots (e.g., “312”)

AgentBinary

Agent binary.

class AgentBinary(NamedTuple)

Attributes

agent Literal['claude_code', 'codex_cli', 'kimi_code', 'opencode']

Agent type.

version str

Agent version.

path Path

“Agent path.

AgentBinaryInstall

Provenance of the agent binary a sample actually ran.

Recorded as the data of an InfoEvent (source="inspect_swe") each time an agent resolves its binary, so a sample that invokes two agents (or the same agent twice) carries one record per invocation. The event exists because the installed version can differ from the one the task appears to request, and can differ between samples of a single eval: "stable"/"latest" resolve through a per-process cache with no expiry, so a resumed run, an eval_set retry, or a multi-process run can install a newer release for the remaining samples, and "auto" takes whatever the sandbox image happens to contain.

class AgentBinaryInstall(BaseModel)

Attributes

agent str

Agent the binary belongs to (e.g. "claude_code").

requested str

version= as the caller passed it: "auto", "sandbox", "stable", "latest", or an explicit version.

version str | None

Concrete version installed. When origin="sandbox" the binary was already in the image, so this is the version codex_cli reads from codex --version, and None for the other agents, which do not run the binary to ask.

platform SandboxPlatform | None

Platform the artifact was resolved for. None when origin="sandbox", where no platform-specific artifact is chosen and detection would add three sandbox execs to the default path.

checksum str | None

SHA-256 of the host-side artifact this install resolved: the binary itself, or the package archive extracted into the sandbox. None when origin="sandbox", where the host never reads the binary.

Two caveats. It is not always the digest published upstream: an agent that transforms its download (codex_cli extracting a single binary from a tarball on pre-rust-v0.133.0 releases) installs bytes the manifest never described, while a package archive is cached and extracted verbatim and so does match when a manifest was resolved at all.

And it describes the artifact on the host, not a re-read of the sandbox. When a package for this version is already extracted in the sandbox the write and extract are skipped, so the digest is of the cached archive that install came from rather than of bytes this call placed there.

origin AgentBinaryOrigin

How the binary got into the sandbox.

  • "download": fetched over the network and verified against the resolved digest.
  • "cache": served from the local cache. This is not a claim of verification. A pinned version read on the fast path is not checked against a digest because none is resolved for it, and neither is a cached artifact for an agent with a post_download transform, whose installed bytes cannot be compared against the download digest.
  • "sandbox": already present in the image; nothing was installed.
  • "cache_unverified": resolution or download failed; the cached fallback was installed without checksum verification.

AgentBinaryOrigin

Where the agent binary a sample ran came from.

AgentBinaryOrigin: TypeAlias = Literal[
    "download", "cache", "sandbox", "cache_unverified"
]

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: Sequence[Tool | 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 = ...,
    mcp_ready_timeout: float = ...,
) -> ACPAgent
disallowed_tools list[str] | None

Tool names to disallow.

skills list[str | Path | Skill] | None

Additional skills to make available.

opus_model str | Model | None

Model for opus calls.

sonnet_model str | Model | None

Model for sonnet calls.

haiku_model str | Model | None

Model for haiku / background calls.

subagent_model str | Model | None

Model for subagents.

model str | Model | None
filter GenerateFilter | None
bridged_tools Sequence[Tool | 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
mcp_ready_timeout float

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 = ...,
    auto_review: bool | CodexAutoReview = ...,
    skills: list[str | Path | Skill] | None = ...,
    home_dir: str | None = ...,
    config_overrides: dict[str, str] | None = ...,
    disallowed_tools: list[Literal['web_search']] | None = ...,
) -> ACPAgent
web_search CodexWebSearch

Web search mode. Use "live" for live web search, "cached" for cached web search, or "disabled" to disable web search.

goals bool

Enable Codex goal tools.

auto_review bool | CodexAutoReview

Enable Codex automated approval review (guardian): Codex runs with its own workspace-write sandbox and on-request approvals, with escalations adjudicated by a guardian model. Pass :class:CodexAutoReview to customize the guardian policy and model. Note: guardian adjudication depends on the codex-core embedded in the codex-acp adapter honoring approvals_reviewer (Codex CLI >= 0.137.0 behavior); unlike codex_cli(), this cannot be version-checked here. If the embedded core instead surfaces an escalation as an ACP permission request, it is auto-approved.

skills list[str | Path | Skill] | None

Additional skills to make available.

home_dir str | None

Override for CODEX_HOME directory in the sandbox.

config_overrides dict[str, str] | None

Extra Codex config.toml key-value pairs.

disallowed_tools list[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 = ...,
    web_search: bool = ...,
    debug: bool = ...,
    model: str | Model | None = ...,
    filter: GenerateFilter | None = ...,
    bridged_tools: Sequence[Tool | 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 = ...,
    mcp_ready_timeout: float = ...,
) -> ACPAgent
skills list[str | Path | Skill] | None

Additional skills to make available.

version Literal['auto', 'sandbox', 'stable', 'latest'] | str

Version of gemini CLI to use. One of: "auto", "sandbox", "stable", "latest", or a specific semver version string.

web_search bool

Enable the agent’s web search tool (defaults to True).

debug bool

Run gemini-cli with --debug and GEMINI_DEBUG_LOG_FILE set to $HOME/gemini-debug.log in the sandbox (in ACP mode console output is patched away from stderr, so the log file is the only way to surface internals).

model str | Model | None
filter GenerateFilter | None
bridged_tools Sequence[Tool | 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
mcp_ready_timeout float

bridge_mcp_to_acp

Convert bridge MCPServerConfigHTTP objects to ACP HttpMcpServer.

def bridge_mcp_to_acp(configs: list[MCPServerConfigHTTP]) -> list[HttpMcpServer]
configs list[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]]
proc ExecRemoteProcess