Agent Bridge
Overview
While Inspect provides facilities for native agent development, you can also very easily integrate agents created with 3rd party frameworks like OpenAI Agents SDK, Pydantic AI, and LangChain, or use fully custom agents you have developed or ported from a research paper. You can also use CLI based agents that run within sandboxes (e.g. Claude Code, Codex CLI, or Gemini CLI).
Agents are bridged into Inspect such that their native model calling functions are routed through the current Inspect model provider. There are two types of agent bridges supported:
Bridging to Python-based agents that run in the same process as Inspect via the agent_bridge() context manager.
Bridging to agents that run in a sandbox via the sandbox_agent_bridge() context manager (these agents can be written in any language).
We’ll cover each of these configurations in turn below. You can also learn from the following examples:
| OpenAI Agents SDK | Demonstrates using a native Open AI Agents SDK agent to perform Q/A using web search. |
| LangChain | Demonstrates using a native LangChain agent to perform Q/A using the Tavili Search API |
| Pydantic AI | Demonstrates using a native Pydantic AI agent to perform Q/A using web search. |
| Claude Code | Demonstrates using a Claude Code agent to explore a Kali Linux system. |
| Codex CLI | Demonstrates using a Codex CLI agent to explore a Kali Linux system. |
Agent Bridge
agent_bridge() runs the agent and its tools in the Inspect process, with access to the host’s network and files. Don’t use it with adversarial models (see Adversarial Models).
The agent_bridge() can bridge agents written against the Python APIs for OpenAI Completions, OpenAI Responses, Anthropic, and Google. To bridge a Python based agent running in the same process as Inspect:
Write your custom Python agent as normal using the OpenAI, Anthropic, or Google connector provided by your agent system, specifying “inspect” as the model name.
Run your custom Python agent within the agent_bridge() context manager which redirects OpenAI calls to the current Inspect model provider.
For example, here we build an agent that uses the OpenAI SDK directly (imaging using your favourite agent framework in its place):
from openai import AsyncOpenAI
from inspect_ai.agent import (
Agent, AgentState, agent, agent_bridge
)
from inspect_ai.model import messages_to_openai
@agent
def my_agent() -> Agent:
async def execute(state: AgentState) -> AgentState:
async with agent_bridge(state) as bridge:
client = AsyncOpenAI()
await client.chat.completions.create(
model="inspect",
messages=messages_to_openai(state.messages)
)
return bridge.state
return execute- 1
-
Use the agent_bridge() context manager to redirect the OpenAI API to the Inspect model provider. Pass the
stateso that the bridge can automatically keep track of changes tomessagesandoutputbased on model calls passing through the bridge. - 2
-
Use the OpenAI API with
model="inspect", which enables Inspect to intercept the request and send it to the Inspect model being evaluated for the task. - 3
-
Convert the
state.messagesinput into native OpenAI messages using the messages_to_openai() function. - 4
-
Return the
statechanges automatically tracked by thebridge.
The OpenAI Agents SDK, PydanticAI LangChain example provide a more in-depth demonstration of using the Python agent bridge with Inspect.
Sandbox Bridge
The sandbox_agent_bridge() can bridge agents written against the OpenAI Completions, OpenAI Responses, Anthropic API, or Google API. To bridge an agent running in a sandbox to Inspect:
Configure your sandbox (e.g. via its Dockerfile) to contain the agent that you want to run. The agent should be configured to talk to the OpenAI, Anthropic, or Gemini API on localhost port 13131 (e.g.
OPENAI_BASE_URL=http://localhost:13131/v1,ANTHROPIC_BASE_URL=http://localhost:13131, orGOOGLE_GEMINI_BASE_URL=http://localhost:13131/v1beta).Write a standard Inspect agent that uses the sandbox_agent_bridge() context manager and the
sandbox().exec()method to invoke the custom agent.
The sandbox bridge works via running a proxy server inside the sandbox container which receives requests for the OpenAI, Anthropic, and Google APIs. This proxy server in turn relays requests to the current Inspect model provider.
The proxy listens on the sandbox’s loopback interface and is reachable only by processes running inside the sandbox, such as the agent binary launched with sandbox().exec(). It is not a browser-facing service: it sends no cross-origin headers, does not answer preflight requests, and accepts only application/json request bodies. A web page rendered inside the sandbox therefore cannot reach the model or bridged tools through the proxy: a request that needs a preflight is refused by the browser, and a request sent without one carries a body type the proxy rejects before any handler runs.
For example, here we build an agent that runs a custom agent binary (passing it input on the command line and reading output from stdout):
from openai import AsyncOpenAI
from inspect_ai.agent import (
Agent, AgentState, agent, sandbox_agent_bridge
)
from inspect_ai.model import user_prompt
from inspect_ai.util import sandbox
@agent
def my_agent() -> Agent:
async def execute(state: AgentState) -> AgentState:
async with sandbox_agent_bridge(state) as bridge:
prompt = user_prompt(state.messages)
result = sandbox().exec(
cmd=[
"/opt/my_agent",
"--prompt",
prompt.text
],
env={"OPENAI_BASE_URL": f"http://localhost:{bridge.port}/v1"}
)
if not result.success:
raise RuntimeError(f"Agent error: {result.stderr}")
return bridge.state
return execute- 1
-
Use the sandbox_agent_bridge() context manager to redirect the OpenAI API to the Inspect model provider. Pass the
stateso that the bridge can automatically keep track of changes tomessagesandoutputbased on model calls passing through the bridge. - 2
- Extract the last user message from the message history with user_prompt().
- 3
- Run the agent, using a CLI argument for input and stdout for output (other agents may use more sophisticated encoding schemes for messages in and out).
- 4
-
Redirect the OpenAI API to talk to a proxy server that communicates back to the current Inspect model provider. Note that we read the
portto listen on from thebridgeyielded by the context manager. - 5
-
Return the
statechanges automatically tracked by thebridge.
The Claude Code and Codex CLI agents in the Inspect SWE package provide more in-depth demonstrations of running custom agents in sandboxes.
Granted Capabilities
Some tools a bridged agent can request are executed outside the sandbox — web_search, web_fetch, code_execution, and remote MCP servers all run at the model provider. An agent that names one of these in a request therefore reaches the network regardless of the sandbox’s own egress policy, so sandbox_agent_bridge() withholds them unless the evaluation grants them:
async with sandbox_agent_bridge(state, web_search=True) as bridge:
...Pass True to use the target model’s internal provider, a WebSearchProviders configuration to select providers explicitly, or leave the default to withhold. code_execution works the same way, and client_mcp_servers=True honors MCP servers named by the agent (prefer Bridged Tools for servers you choose yourself). Whenever a declared tool is withheld a warning is logged, since an absent tool is otherwise indistinguishable from the model declining to call it.
Ordinary function tools are never withheld — those are executed by the bridged agent inside the sandbox and grant it nothing it does not already have.
For the same reason, all media content (images, audio, video, and documents) in a request to a sandbox bridge must be an inline data: URI. A remote URL or host path would otherwise be dereferenced outside the sandbox, on the agent’s behalf.
Request headers are granted the same way. Apart from Accept-Encoding, sandbox_agent_bridge() drops every header the agent’s SDK sends, since a header can change the billing, limits, or behavior of the host’s requests (for example anthropic-beta, which turns on Anthropic beta features). To forward one, list the header and the values the agent may send for it:
async with sandbox_agent_bridge(
state,
forward_client_headers={"anthropic-beta": ["context-management-2025-06-27"]},
) as bridge:
...Header names are case-insensitive. A comma-separated value is checked one item at a time, so list each item separately (a listed value cannot contain a comma). Items you did not list are dropped with a warning, and the header is dropped if none remain. A header you did not list is logged once by name. Accept-Encoding cannot be listed. Credentials (such as Authorization, x-api-key, api-key, x-goog-api-key, and AWS x-amz- headers) and transport headers (such as Host and Content-Type) cannot be forwarded. On both bridges, a forwarded Accept-Encoding keeps only the encodings Inspect can decode (br needs the brotli package, and zstd needs Python 3.14 or the backports.zstd package).
Headers configured on the Inspect model itself (e.g. the Anthropic betas model arg or extra_headers) are always sent. When the model or eval sets extra_headers, they are merged with the forwarded headers: their value wins for a header both set, except that anthropic-beta values are combined.
None of this restricts the in-process agent_bridge(), where the scaffold already runs with the host’s network and filesystem and there is no boundary to defend. Inspect explicitly materializes its non-inline media before model submission, preserving that access without relying on provider-side fetching.
AgentBridge itself defaults to rejecting non-inline media so a new bridge subclass cannot accidentally grant host access. Code that constructs the class directly can opt in with allow_remote_media=True; the agent_bridge() factory makes this grant explicitly.
Bridged Tools
Host-side Inspect tools can be exposed as MCP tools to sandboxed agents using the bridged_tools parameter. This is useful when you have Inspect tools that need to run on the host (e.g. tools that access host resources, databases, or APIs) but want them available to agents running in a sandbox.
To bridge tools, wrap them in a BridgedToolsSpec and pass to sandbox_agent_bridge():
from inspect_ai.tool import tool
from inspect_ai.agent import (
Agent, AgentState, agent, sandbox_agent_bridge, BridgedToolsSpec
)
from inspect_ai.util import sandbox
@tool
def search_database():
async def execute(query: str) -> str:
"""Search the internal database.
Args:
query: The search query.
"""
# Runs on the host, not the sandbox
return f"Results for: {query}"
return execute
@agent
def my_agent() -> Agent:
async def execute(state: AgentState) -> AgentState:
async with sandbox_agent_bridge(
state,
bridged_tools=[
BridgedToolsSpec(
name="host_tools",
tools=[search_database()]
)
]
) as bridge:
# bridge.mcp_server_configs contains resolved MCPServerConfigStdio
# objects that can be passed to CLI agents
return bridge.state
return executeThe bridge handles:
- Starting a host-side service that executes the Inspect tools
- Writing an MCP server script to the sandbox that forwards tool calls to the host
- Returning MCPServerConfigStdio configs that CLI agents can use to connect
Bridged tool arguments are checked as for other tool calls: arguments nested more than 100 levels deep, or that do not match the tool’s parameters, are rejected with a parsing error the agent returns to the model. The nesting check comes first; a call the model did not propose is then denied before its arguments are checked against the tool’s parameters.
Bridged tool results are truncated in the same way as other tool results: at the tool’s own max_output if it declares one, otherwise at max_tool_output from the generate config (16KB by default). Results returned as content (e.g. list[ContentText]) are not truncated, as for other tools.
Execution Contract
Bridged tools execute only for calls the model proposed in a bridged generation, once per proposal. Each tool call in a model response handed to the agent grants one execution of exactly that tool with exactly those arguments (as approved, or as modified by an approval policy); a tools/call request with no matching grant is denied and the error is returned to the agent, which surfaces it to the model. This holds whether or not an approval policy is active. Tool discovery (tools/list) is unaffected.
Two consequences follow:
- An agent that retries a
tools/callafter a transport failure is denied, since the proposal has already executed once. The agent should return the error to the model, which re-proposes the call. - Only the primary choice of a multi-choice response is granted; alternate choices that carry tool calls are dropped (with a warning). Request a single choice (
n=1) from a bridged agent.
If a tool’s parameters do not allow additional properties, the call may leave out proposed arguments the tool does not declare. Some agents add such fields for their own use and drop them before calling the tool; the tool could not accept them anyway.
An agent that legitimately calls a host tool programmatically, outside a model turn, can opt a server out with require_proposal=False. That server’s tools then execute for any tools/call it receives, and the bridge no longer guarantees that they run only for calls the model made:
BridgedToolsSpec(
name="host_tools",
tools=[search_database()],
require_proposal=False,
)Some agents call MCP tools from code the model writes instead of offering each tool to the model. Codex CLI does this for models its catalog marks code_mode_only (most current GPT models): the model writes JavaScript for an exec tool, and the script calls tools.mcp__<server>__<tool>(...). The model’s only proposal is the exec call, so the bridge has nothing to match those calls against and denies all of them. Such an agent needs require_proposal=False on every bridged server it uses. The bridge cannot tell these calls from any other unproposed call: it neither detects code mode nor fails the sample, and logs the opt-out guidance once per server and tool per process. With the opt-out, approval policies review the exec call that carries the script, not the host tool calls made from it.
Matching a Proposal
Agents rename MCP tools to their models under their own schemes (Claude Code declares mcp__<server>__<tool>, Codex CLI the bare name inside a Responses API namespace (outside code mode; see above), Gemini CLI mcp_<server>_<tool>, OpenCode <server>_<tool>, some cut or hash long names), so the bridge does not match a proposed call by name. It matches the call’s declaration in the agent’s request to a bridged tool by the description the bridge itself served in tools/list. A declaration whose description matches no bridged tool denotes nothing and the call is denied. Tools an agent discovers through the Responses API’s tool_search (declared to the model inside a tool_search_output item rather than the request’s tool list) count as declarations too. Two or more bridged tools the served content cannot tell apart are each granted by a proposal for any of them: one proposal then authorizes one execution of each, still bound to the proposed arguments. An empty description is matched like any other, so an undocumented bridged tool is indistinguishable from every other undocumented tool. The bridge warns at setup, naming the tools that share a description (an empty one included); give bridged tools distinct docstrings to keep matching one-to-one. The supported agents forward the served description to their models unchanged. An agent that truncates long descriptions is tolerated: a declaration that agrees with a served description for at least 64 characters and adds at most a short trailing marker identifies that tool. An exact description match wins even when that description is a prefix of another bridged tool’s; a truncated declaration that could refer to both grants both. An agent that rewrote the leading text would be denied on every call. An agent-local tool declared with a bridged tool’s exact description is indistinguishable from it: a call to it grants the bridged tool and is approved under the bridged tool’s name, so policies scoped only to the local name do not apply.
One other shape is recognized: an agent that exposes every MCP tool through a single dispatcher function, Antigravity’s call_mcp_tool, whose arguments carry string ServerName and ToolName values naming a bridged tool and an object Arguments. Such a call denotes that tool with those nested arguments. The dispatcher is recognized by that function name together with the argument shape, so an ordinary tool call cannot denote a bridged tool by naming it in its arguments; a dispatcher with another name or other parameter names is not supported and its calls are denied.
Models
As demonstrated above, an agent reaches the eval’s model by naming the model "inspect".
With the in-process agent_bridge(), you can reach other Inspect models by prefacing the fully qualified model name with inspect/. For example, in a LangChain agent, you would do this to use the Inspect interface to Gemini:
model = ChatOpenAI(model="inspect/google/gemini-1.5-pro")The sandbox_agent_bridge() serves only models the eval chose. A request is routed as follows:
- A name in
model_aliasesgoes to the model it maps to. - A name the
model_resolverreturns a model for goes to that model. "inspect", and the eval’s own model name (e.g.claude-sonnet-5-5for an eval onanthropic/claude-sonnet-5-5), go to the eval’s model.- Any other name, including
inspect/<model>names and model role names, also goes to the eval’s model. The bridge logs a warning once for each such name, and therequested_modelfield of the model event in the transcript records the name the agent sent.
Pass model to send unmatched names (and the eval’s own model name) to another model instead, e.g. model="inspect/openai/gpt-6-luna".
Agents often call more than one model: Claude Code, for example, makes background calls to a smaller model. These calls are served by the eval’s model unless you map the names. To send a name to another model, add it to model_aliases. Keys are the exact names the agent sends, as shown in the warning. To send a sub-agent tier to a model role you define for it, map the name to get_model(role=...):
from inspect_ai.model import get_model
async with sandbox_agent_bridge(
state,
model_aliases={
"claude-haiku-5-5": get_model("anthropic/claude-haiku-5-5"),
"subagent": get_model(role="subagent"),
},
) as bridge:
...Every alias key is a model the agent can call, so do not alias a role the agent should not reach, such as a grader or monitor.
Names for the eval’s own model need no alias. They already get the eval’s model with its generation config, which an alias to a model name string would not.
Generation Config
Bridged agents typically tune their requests (e.g. max_tokens, temperature, reasoning effort) for the model named in their own configuration, which is not the Inspect model actually serving the request. Those values are therefore targeted for the wrong model, and forwarding them can produce incorrect or even failing requests (for example a small max_tokens combined with reasoning being enabled on the real model).
For this reason, by default the bridge does not forward client generation parameters. Instead, the resolved Inspect model configuration and the provider’s defaults govern generation. Structural parameters that express the agent’s intent — the system prompt, tools, tool choice, response format, stop sequences, and seed — are always forwarded.
The generation parameters dropped by default are: max_tokens, temperature, top_p, top_k, frequency_penalty, presence_penalty, n/num_choices, logprobs, top_logprobs, logit_bias, and reasoning effort/tokens/summary/mode.
If you want the bridge to act as a faithful proxy where the agent’s generation parameters are authoritative, pass forward_generation_config=True:
async with agent_bridge(state, forward_generation_config=True) as bridge:
...This option is available on both agent_bridge() and sandbox_agent_bridge(). Values set in the Inspect model’s own configuration still take precedence over the agent’s. When the model uses the OpenAI Responses API, reasoning fields that Inspect does not model (e.g. context) are passed through as the agent sent them. They go only on the bridge’s own generation: a bridge filter that calls generate() itself gets the effort, summary, and mode in config but not these fields, so return GenerateInput from the filter to have them sent.
Request Settings
Some request fields and tool options change billing, storage at the model provider, how much of the conversation the provider keeps, or what provider tools may do. On both agent_bridge() and sandbox_agent_bridge() the eval’s configuration decides these, not the agent:
service_tier,storeandtruncation(OpenAI Responses) andservice_tier(Anthropic) are not forwarded. Set them with the provider’s model args (for OpenAI,-M service_tier=flexor-M responses_store=true) or withGenerateConfig(extra_body=...). If the agent asks for a different value, a warning is logged once per field.A Responses request with
previous_response_idis refused with a 400 error (raised as aBridgePolicyErrorfrom the client call for agent_bridge()). The bridge keeps no stored responses, so the agent must send the whole conversation ininput.metadata,safety_identifier,prompt_cache_key,prompt_cache_retentionandmax_tool_callsare forwarded.Options the agent sets on a provider tool it declares do not replace the bridge’s
web_searchandcode_executionoptions. This covers the code interpreter’scontainer(OpenAI), and web search filters and allowed or blocked domains (OpenAI and Anthropic). For anything that differs, a warning is logged once per tool.The agent may set a web search
user_location(OpenAI and Anthropic) orsearch_context_size(OpenAI) that the bridge’sweb_searchoptions leave unset. These shape the results but do not widen what can be searched.search_context_sizecan change cost, because OpenAI bills search content tokens; to control that cost, set it in the bridge’sweb_searchoption. When the eval sets one, the eval’s value is used.The agent may choose the Anthropic web search tool version (its
type, such asweb_search_20250305) when the bridge’sweb_searchoptions set none. A version Inspect does not support is dropped and Inspect picks one.The agent may also ask for less: a lower Anthropic
max_uses, or OpenAIexternal_web_access: false, is applied.An OpenAI computer tool needs storage at the provider. If the eval turns storage off (
-M responses_store=falseorstore: FalseinGenerateConfig(extra_body=...)), a request that declares the computer tool is refused with a 400 error. When the eval does not set storage, Inspect turns it on for these requests, as it does for any OpenAI computer tool.
OpenAI Chat Completions and Google requests forward none of these fields, and Google tool declarations carry no options into the request.
HTTP headers an agent sends to the sandbox bridge’s proxy are forwarded only as described in Sandbox Bridge: Accept-Encoding and the headers listed in forward_client_headers. In-process, request body settings follow the eval as above, while the agent’s headers are forwarded as before, apart from credential, transport and SDK headers.
Tool Approval
Tool calls made by a bridged agent can be governed by approval policies, even though the agent executes its own tools. Approval is applied to the tool calls in each model response before that response reaches the agent, so a rejected call is never run. Web search and code execution that the model provider runs for the agent (granted with web_search or code_execution) are not reviewed by approval (see Provider-Run Tools), and remote MCP servers are refused while a policy is active (see Remote MCP Servers).
Eval-level and task-level policies apply automatically; both agent_bridge() and sandbox_agent_bridge() also accept an approval parameter:
from inspect_ai.approval import ApprovalPolicy, auto_approver, human_approver
async with sandbox_agent_bridge(
state,
approval=[
ApprovalPolicy(human_approver(), "bash"),
ApprovalPolicy(auto_approver(), "*"),
],
) as bridge:
...Rejection works by telling the model rather than by editing the response: the rejected call and an explanation are replayed to the model, which then generates again. The agent sees only the replacement, so its loop continues normally. See Bridged Agents for the full semantics.
For bridged_tools, the approved call is also what the agent may execute on the host: a bridged tool runs once per proposed call, with the arguments as approved or modified (see Execution Contract).
A call to a bridged tool is approved under the bridged tool’s own name, whatever name the agent declared it under: the bridge identifies the tool by its description (see Execution Contract), so policies match the tool that will run. A call that could be several bridged tools sharing a description is approved only if each of them is approved, and a modify decision for it fails the sample. Each of those approvals is logged as its own ApprovalEvent under the call’s id, and Sentinel replay of the log keeps only the last of them, so a person’s earlier review of one of the tools is not among the replayed human decisions. As for other tool calls, only a modify decision changes a call’s arguments: a modified call attached to an approve decision is ignored, and a call an approver changed in place and approved is rejected. An agent that reaches every bridged tool through one dispatcher function (Antigravity’s call_mcp_tool) is approved as if the model had called the bridged tool directly: policies match the tool’s own name, and approvers see and modify the tool’s own arguments.
Agent Context
Bridges accept a filter function (the filter parameter of agent_bridge() and sandbox_agent_bridge()) that runs on every bridged model request and can inspect or modify generation. When a bridged agent delegates work to sub-agents, every sub-agent’s model requests flow through the same bridge — so a filter fires for all of them, not just the top-level agent’s. Code that injects steering, counts turns, or ends an episode early from inside a filter should confine itself to the top-level agent.
The ambient agent context tells you which agent the current request belongs to:
from inspect_ai.agent import is_root_agent
async def my_filter(model, messages, tools, tool_choice, config):
if not is_root_agent():
return None # never steer a sub-agent or utility thread
...Within a bridged request, current_agent_bridge_context() carries:
kind—"root"(the top-level agent’s own thread),"subagent"(a delegated agent’s thread),"utility"(internal machinery calls such as compaction or approval review), or"unknown"(no attribution available).subagent_id— for"subagent"requests, an opaque id that is stable across one sub-agent’s requests and distinct between sub-agents, for keeping per-sub-agent state (turn counts, separate steering).Nonewhen the sub-agent can’t be told apart from its siblings, and alwaysNonefor other kinds.subagent_type— for"subagent"requests, the scaffold’s name for the kind of sub-agent (e.g."explore"), orNonewhen it isn’t known.
Outside of a bridged model request it returns None.
Compaction and approval review run as "utility": an approval policy reviewing a bridged request’s tool calls, and any model calls it makes, read "utility" rather than the context of the request under review.
Attribution comes from whoever runs the bridge: bridged agent packages (e.g. inspect_swe) resolve and set the context via set_agent_bridge_context() from their own filter wrappers, and in-process scaffolds that manage their own delegation can do the same — within the current task, the value lasts until the request ends and then resets automatically. Call set_agent_bridge_context() from the filter’s own task: a call made in a task the filter spawns changes only that task’s copy and is silently lost to the request. Likewise, a task spawned during a request keeps the context it started with after the request ends. When nothing sets it, every request reads "unknown" — is_root_agent() deliberately treats "unknown" (and running outside a bridged request) as root, so control code keeps working on bridges with no attribution rather than silently disabling itself. Consumers that instead require positive confirmation of the top-level agent can check current_agent_bridge_context() for kind == "root" explicitly. The narrower is_sub_agent() is True only for "subagent" — note it is False for "utility" calls, so prefer is_root_agent() for steering gates.
Model requests carry one additional ambient fact: current_bridge_request() exposes the model slug the scaffold requested (before model_aliases resolution), or None when the request carried no model. Context resolvers use it to classify traffic that a scaffold routes through distinct model names.
Transcript
Custom agents run through a bridge still get most of the benefit of the Inspect transcript and log viewer. All model calls are captured and produce the same transcript output as when using conventional agents.
Tools the agent runs itself (e.g. its own shell or file tools) appear only in the model calls, as reported by the agent (see Adversarial Models). Bridged tools run by Inspect are recorded as tool events, like other tool calls, including calls that were denied or rejected. A call the model proposed takes the id of the model’s tool call, so the log viewer shows it with that call. Each event’s metadata["bridge"] records the server and tool, the name the model called it by, the id of the proposing call, and whether a proposal matched (grant: "consumed", "denied", "exempt" for a require_proposal=False server, or None for a request rejected before that check). Counts of tool events in a bridged sample (e.g. from events_df()) include bridged tool calls but not the agent’s own tools.
Some providers reuse one tool call id for several calls (e.g. Mistral sends "null" for every call whose id the model omitted). The bridge then gives a later, different call a new id before the agent receives it, so the agent can tell the calls’ results apart. The model event’s output keeps the ids the model sent, and its agent_tool_call_ids field lists the id the agent received for each call, in the same order. The agent’s later messages, including each call’s result, use those ids.
The field is None when every call kept the model’s id. It is also None when a request or response filter returned a copy of the response (changed or not), even if the bridge gave its calls new ids, so a missing field doesn’t prove the agent received the model’s ids. For a turn that tool approval rejected, the agent never received the calls: their ids appear only in the rejection the model is sent next.
Sentinel replay uses these ids to pair each call with its result (see Bridged Agents).
On a require_proposal=False server, a call is paired with the oldest pending proposal for the same tool and arguments, whichever call arrives first. A call the model did not propose (for example, one made from code the model wrote) with the same arguments as a pending proposal takes that proposal’s id, and the proposed call is then recorded as "exempt" with a fresh id. Both calls run as usual; only the pairing in the log is wrong.
If you want to use additional features of Inspect transcripts (e.g. spans, markdown output, etc.) you can still import and use the transcript function as normal. For example:
from inspect_ai.log import transcript
transcript().info("custom *markdown* content")Adversarial Models
An adversarial model is one that may try to bypass controls, tamper with evidence, or manipulate the evaluation (for example, a model without safeguards in a cyber evaluation). If you are evaluating one, keep the following in mind.
Sandbox Bridge
With sandbox_agent_bridge() the agent runs inside the sandbox, so the sandbox is what contains it. By default the bridge keeps the model API keys Inspect uses on the host and withholds tools that run outside the sandbox (see Granted Capabilities). Credentials you put in the sandbox yourself (for example, through an agent’s env) can be read by the agent. Anything you grant, including bridged tools, is available to the agent even if the sandbox has no network. Note that most Inspect SWE agents grant web search by default.
Running the agent inside the sandbox has these limits:
By default, any process in the sandbox can call the bridge. Inspect can’t tell the agent apart from other processes in the sandbox. A framework that runs each agent as its own sandbox user (such as Inspect Swarm) can limit the bridge to that user. The bridge still can’t tell apart processes running as that user, and root can act as any user.
The transcript is the agent’s own account of its tool use. Inspect records model calls, and runs and records any bridged tools you provide. It doesn’t run or check the tools the agent runs inside the sandbox. The message history and tool results in each request come from the agent, which can misreport them. If you need a reliable record of tool calls, use a native agent such as react().
Don’t count on a non-root user. A capable model may get root in its container. Root can interfere with the bridge inside the sandbox, including the responses the agent receives.
The agent’s own permission prompts are usually off. Agents typically run with their permission prompts and sandboxing disabled (Inspect SWE does this by default).
Approval covers tool calls the agent runs, not their effects. Tool approval reviews each tool call before the agent sees it. It doesn’t review what an approved command then does, or web search and code execution run by the model provider. Remote MCP servers are refused while an approval policy is active.
In-Process Bridge
Don’t use agent_bridge() with an adversarial model. The agent and its tools run in the Inspect process with access to the host’s network and files, and Inspect reads the files and URLs that messages reference as media. Use sandbox_agent_bridge() or a native agent instead.
Other Recommendations
Keep
network_mode: none, or allow access only to the hosts the task needs (see Docker Configuration).Don’t enable writable host mounts.
Consider a stronger setup than default Docker. For example, run containers with gVisor’s
runscruntime, which makes container escape harder. A VM-based sandbox gives more protection still (see Environment Binding for the available sandbox providers).Turn off rendering of model content in the log viewer (see Untrusted Content).
Keep log directories out of the agent’s reach, and only retry or rescore logs you trust (see Eval Logs).
If you use
--acp-server, keep it on the default Unix socket. The server has no authentication, so if you use a TCP port make sure the sandbox can’t reach it. A loopback port may not be enough: some setups (for example, Docker Desktop with sandbox networking enabled) let a container connect to the host’s loopback ports (see Intervention).Scorers, graders and monitors that read agent output or sandbox files are reading input the model controls.