python_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. A cloud model can write the code, but the
code runs in a local Docker container.
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./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. The tool reports exit status,
source-call IDs and incomplete inputs or output. Output is limited to
40,000 bytes; longer output is explicitly marked incomplete.
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, then run:
DISALLOWED_TOOLS: [python_exec].