このページの日本語版はまだありません。以下は英語の原文です。
code_exec lets chat models calculate over queried health records, including
comparisons across indicators, medications, genetics and pharmacogenomics.
It receives the original data automatically, so the model does not need to
copy values from a displayed table. Which language the model writes depends
on where the model runs; the tool’s name does not change.
The comparison in the calculation benchmarks
found the cloud models equally correct in both languages. JavaScript needs no
container, so a cloud model has a calculator in every deployment, including
the main Compose file alone.
Inputs and outputs
The code can use:data: original rows from the latest successful, nonempty record query.results: successful query results from the current turn, including metadata, assumptions, source information and tool-call IDs.- In Python only,
/workspace/data.json: the samedataandresultsinside the calculation container. This is not a path for uploading or reading documents.
stats and time-bucket views for the aggregates
they already provide.
Code should print its result and source rids: print(...) in Python,
console.log(...) in JavaScript, where the value of a final expression is
returned as well. The tool reports exit status, source-call IDs and incomplete
inputs or output. Output is limited to 40,000 characters; longer output is
explicitly marked incomplete.
JavaScript
The engine is QuickJS compiled to WebAssembly and run on wasmtime inside the app process: the one under the Deep Agents interpreter, without its tool bridge, so code reads only the injected rows. Each call gets a fresh engine with 128 MB of memory and a 1–30 second deadline, with up to ten additional seconds for the host to wait. The standard built-ins (Math,
JSON, Date) are there; the network, files, a process, require and
import are not. There is nothing to set up.
Python
Local setup
For a source installation, install the application dependencies and download the calculation image:PYTHON_SANDBOX_DOCKER_HOST, DOCKER_HOST,
/var/run/docker.sock, then the active Docker CLI context. Only local Unix
sockets are accepted; TCP and SSH endpoints are rejected.
The default image provides Python’s standard library. To add analysis
packages, prepare a local image and set PYTHON_SANDBOX_IMAGE. Install its
dependencies in advance: calculation containers have no network access.
When the app also runs in Docker
The app needs access to the host’s Docker daemon to start calculation containers. The optional compose-python.yaml mounts the management socket into the app, granting it permission to manage containers. This is opt-in; the main Compose file does not mount the socket. Calculation containers never receive it. SetPYTHON_DOCKER_SOCKET to the socket path on the Docker host and
PYTHON_DOCKER_GID to its owning group ID as the daemon sees it (Colima
reports 991), which this prints:
When no daemon answers
The app asks the daemon once, at startup, and only when a chat model runs on this machine or your own network. When nothing answers (the main Compose file alone, a socket whose group the app is not in, Docker not running), local models compute in JavaScript too, and the log says so once:Turning it off
SetDISALLOWED_TOOLS: [code_exec]. The tool’s earlier names, python_exec
and eval, are read as code_exec, with a warning in the log.