AIVAX

Shell Sandboxing

AIVAX offers a virtual shell environment that can be used by agent assistants to execute terminal commands during inference. This feature is especially useful for tasks such as data manipulation, API calls, script execution, and workflows that are easier to express as command-line operations.

The shell environment allows moving selected model tools to the shell side, turning them into CLI commands. This is useful when you have many tools and do not want to expose all of them directly to the model, or when a tool is easier to use through command-line arguments and pipes.

When enabled in an AI Gateway, the model sees a shell tool with one argument: command. Commands run in a sandboxed shell with a workspace mounted at /home/workspace. Each command has a time limit and a cap on the output returned to the model; see Pricing and limits.

Design for the limits #

The command timeout and output cap shape how shell tools should behave. Keep commands fast and their output narrow: filter server-side with grep, awk, or query flags before printing, and prefer tools that return CSV or line-delimited rows the model can slice with pipes. When a result legitimately exceeds the cap, split the work — one command to list or count, follow-ups to fetch slices — or write the full output to a workspace file and read the relevant part back through the Shell file API below.

Long-running operations do not belong in an inference command. Move exports, bulk transforms, and polling loops to Batch or an external job, and let the shell handle the interactive slices.

Adapting tools for shell #

In the virtual shell interface, standard command-line utilities and registered shell modules are available. This way, you can adapt your tools to return raw or long outputs, and the model can use the shell’s text manipulation tools to extract the relevant information, for example:

Bash
get-users --filter active --format csv | grep "John Doe" | awk -F, '{print $1, $2}'

In the line above, get-users is a custom tool that returns a list of users in CSV format. The grep command filters the results to find “John Doe”, and awk extracts and formats the desired columns. This tool may have been defined by MCP, built-in tools or be a protocol tool.

Tools moved into the shell are no longer exposed as direct model functions, except reserved tools such as shell and read_skill. Configure the shell tool list as either:

  • WhiteList: only listed tools are exposed as shell commands.
  • BlackList: listed tools remain direct model tools, and the other non-reserved tools are exposed as shell commands.

Use the runtime function name when listing tools, such as web_search, open_url, request, or a protocol/MCP function name. Each shell command generated from a tool supports --help and maps JSON Schema properties to command-line options.

Prefer the whitelist when the model needs a small, predictable command set. Prefer the blacklist when most tools are shell-friendly and only a few must stay as direct functions.

Data persistence #

It is possible to define data persistence for the shell environment. When allowDataPersistence is enabled and the inference context has a user external ID, AIVAX mounts a persistent workspace scoped to the account and user. This allows the agent to keep files across conversations and sessions for that identified user.

If persistence is disabled, or the inference context has no user external ID, the shell uses an in-memory filesystem and the workspace is discarded after the inference iteration.

Enable persistence only for data the user expects to survive — working documents, generated reports, configuration they manage. Keep secrets, credentials, and other users’ data out of the persistent workspace: anything written there endures beyond the session that created it.

Internet access #

By default, the shell has internet access through curl, wget and ping. Set bashOptions.allowInternetAccess to false to remove the network commands and run fully offline.

Pricing and limits #

The number of Bash commands per hour depends on the plan; see Built-in tools and web search limits. These limits apply to every plan:

LimitValue
Time per command60 seconds
Output returned to the model4,096 characters
Shell file API upload100 MB maximum request body

Shell file API #

AIVAX also exposes Shell I/O endpoints under /api/v1/shell/io for authenticated accounts. Every request requires the X-Shell-User-Id header, which scopes the filesystem sandbox the endpoint operates on.

With these endpoints, you can list directories, download files, inspect file metadata, create temporary public file addresses, upload files, create directories, and delete files or directories. Uploads have a maximum request body size; see Pricing and limits.

Reference:

Type to search the documentation.