Skip to main content

Sandbox container tool code for inspect_ai

Project description

Multi-tool Shared Image

diagram

Stateless / Stateful Design

Inspect calls into the sandboxed image are done statelessly via docker exec python multi-tool.py.

Some tools can be implemented without the need for any in-process state. For those tools, the tool code will be executed within the multi-tool.py process.

For tools that require the maintenance of state over the lifetime of and sandbox, this image marshals tool calls into a long running process via JSON RPC to an http server process. That server then dispatches tool calls to tool specific @method handlers.

Stateful Tool Design Pattern

Each stateful tool should have its own subdirectory that contains the following files:

  • json_rpc_methods.py

    This module contains all of the JSON RPC @method functions — one for each tool (e.g. the web browser tool is actually a set of distinct tools). It is responsible for unpacking the JSON RPC request and forwarding the call to a transport-agnostic, strongly typed, stateful controller.

  • tool_types.py

    This module includes the pydantic models representing the types for tool call parameters and results.

  • controller.py

    This is transport-agnostic, strongly typed code that manages the tool specific in-process state and performs requested commands.

Compatibility

The Inspect framework will insure that the most recently published image of a particular tag will be downloaded when an eval is executed. This means that, from a cross-version perspective, we only have to worry about old tool code interacting with newer container code. The inverse is not possible.

Because of this, when publishing new major version images, care must be taken to retain the old version entrypoint called by tools.

For example, older versions of the web_browser_tool() performed docker exec's against /app/web_browser/web_client.py and /app/web_browser/web_client_new_session.py. A newer version of the image changed the entry point to /opt/inspect/multi-tool-v1.py.

This means that newer versions of the image must retain the old entry points in a backwardly compatible way. Typically, the implementation of those old entry points will be updated to adapt and call the new version of the code.

[!TIP] For this reason, it is a best practice to include a version number in the filename of the docker exec entry points.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inspect_tool_support-0.1.3.tar.gz (57.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inspect_tool_support-0.1.3-py3-none-any.whl (68.6 kB view details)

Uploaded Python 3

File details

Details for the file inspect_tool_support-0.1.3.tar.gz.

File metadata

  • Download URL: inspect_tool_support-0.1.3.tar.gz
  • Upload date:
  • Size: 57.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for inspect_tool_support-0.1.3.tar.gz
Algorithm Hash digest
SHA256 89f8a00909c9201f2425d73345666f1f5060f515f7af560d5aa716fc311c3fcf
MD5 eb67d725446fccfec61381c16fc93c6b
BLAKE2b-256 ddce10dd68fca94ac3a9d32342469aa042393dfb5336d338fc2714c2a644ef15

See more details on using hashes here.

File details

Details for the file inspect_tool_support-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for inspect_tool_support-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 43774435bb3fef3d1c604bb6d900d0fa95168500e1385eb1cf9cb85b01f1c48e
MD5 0823cb11ca61d78ee74d36051a204c26
BLAKE2b-256 65d98b962f51a4697a30446bce3ad8ef4a1bc41f13b7a7d692cb69a7ba0878fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page