/ailoy:ailoyfrom ailoy
Builds AI agents with a Linux micro-VM sandbox for running code, installing software, and managing files. Supports Python, Node.js, and Rust with multiple model backends.
Ships in ailoy. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
An agent gets a sandbox: a Linux micro-VM booted from an image you name, with only the volumes you mount. A model drives it turn by turn, asking for tools and getting their results back, until it has nothing more to ask. So "an agent that writes code and runs it" is a builder call, not a tool loop you assemble.
Work the steps below in order. Step 3 is the one that gets skipped: an agent given tools but no sandbox has nowhere to run them.
| Language | Install | The sandbox comes from |
|---|---|---|
| Python | pip install ailoy-py | from virtx import Client, Recipe, SandboxVolume |
| Node.js | npm install @brekkylab/ailoy @brekkylab/virtx | require('@brekkylab/virtx') |
| Rust | ailoy = "0.3", virtx = "0.2" in Cargo.toml | virtx::{Client, SandboxCreateArgs} |
The sandbox is virtx's: Ailoy takes a Sandbox made with virtx's own package and adds no sandbox API of its own. A sandbox runs on virtx's server, which Client.spawn() (Client::spawn_virtx in Rust) starts, fetching it into virtx's cache the first time. The sandboxes a spawned server holds go when its client is closed or the program ends.
A model is <org>/<name>: the maker's own name for it, the official API id for Claude, GPT and Gemini (anthropic/claude-haiku-5-5, openai/gpt-5.6-luna, google/gemini-3.1-pro) the Hugging Face repo id for open-weight models (deepseek-ai/DeepSeek-V3.2), and the API id for a model with no repo (LGAI-EXAONE/k-exaone_v2.5). The name stays the same whichever backend runs it; the org's backend decides that.
| Backend | Runs the model through | Needs |
|---|---|---|
cli (default for anthropic, openai, google) | The org's CLI on its own login (OAuth): Claude Code claude, Codex codex, Gemini CLI gemini | The CLI on PATH, already logged in |
api (default for the other orgs) | The org's own API | ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, DEEPSEEK_API_KEY, ... |
bedrock | Amazon Bedrock | AWS_BEARER_TOKEN_BEDROCK, and AWS_REGION (else us-east-1) |
openrouter | OpenRouter | OPENROUTER_API_KEY |
self-hosted | A server you run yourself: vLLM, llama-server, Ollama, LM Studio, SGLang, or another endpoint serving the OpenAI-compatible Chat Completions API. The model keeps its name whatever the server calls it | SELF_HOSTED_BASE_URL |
So with Claude Code, Codex or Gemini CLI logged in on the host, no key is needed: AgentBuilder("anthropic/claude-haiku-5-5") runs on that login, and AgentBuilder("anthropic") alone runs the CLI's default model. To use a key instead, switch the org's backend before building the agent:
import ailoy
ailoy.set_lang_model_provider("anthropic", "api") # every anthropic/ model built after this uses ANTHROPIC_API_KEY
Node is setLangModelProvider('anthropic', 'api'); Rust is ailoy::model::set_lang_model_provider("anthropic", Backend::Api). A server per org, instead of the one in the environment, is the backend with its URL, and models when the server calls a model something else: ailoy.set_lang_model_provider("meta-llama", {"backend": "self-hosted", "base_url": "http://localhost:11434/v1", "models": {"Llama-3.3-70B-Instruct": "llama3.3:70b"}}) runs meta-llama/Llama-3.3-70B-Instruct on Ollama.
Keys are read from the environment when the model is built, so set them before that; a missing one fails at build() with ANTHROPIC_API_KEY is not set. A CLI that is not installed fails only at the first turn, with failed to start the claude CLI. Pick the CLI when the user is running it on their own machine with a subscription, and a key when it runs unattended (CI, servers) where nobody can log in. docs/content/guides/model-providers.mdx has which org runs on which backend.
Decide what the agent's machine holds before writing the agent: the image is where its software comes from, and volumes are how files go in before a run and come out after.
from virtx import Client, Recipe, SandboxVolume
client = Client.spawn() # starts virtx's server, fetched into its cache the first time
recipe = Recipe("python:3.12-slim-trixie").run("pip install matplotlib")
await client.build_image(recipe, "plot:latest").complete()
artifacts = await client.create_volume("plot-artifacts") # kept on the server; `409` if it is there
sandbox = await client.create_sandbox(
"plot:latest",
volumes=[SandboxVolume(volume=artifacts, path="/artifacts")], # where its output is read back from
network=False, # on unless turned off
)
Recipe is a base image plus steps, as a Dockerfile is. Build it once under a name and check client.list_image() before building again, so the agent does not install its software every run.write_file, mount it at an absolute guest path (readonly=True for an input), and read what the agent wrote from it with read_file and read_dir after the run.Node is the same calls in camelCase, with the options as an object (createSandbox('plot:latest', { volumes: [{ volume: artifacts, path: '/artifacts' }] })); Rust builds SandboxCreateArgs::new("plot:latest").volume(artifacts.name(), "/artifacts"). docs/content/guides/sandbox.mdx has images, volumes, CPUs, memory and the GPU.
from ailoy import AgentBuilder
agent = await (
AgentBuilder("anthropic/claude-haiku-5-5")
.instruction("Write what you are asked for into /artifacts.")
.sandbox(sandbox)
.build()
)
What else the builder takes, by what the task needs:
| The agent should | Builder call |
|---|---|
| read the web | .web_fetch_tool(), .web_search_tool([...]) |
| use an MCP server's tools | tools = await register_mcp_stdio("fetch", "uvx", ["mcp-server-fetch"]), then .tools(tools); register_mcp_streamable_http(prefix, url) for a remote one |
| call your own function | desc = register_tool({"name": ..., "description": ..., "parameters": <JSON schema>}, func), then .tool(desc) |
| drive a web browser | .browser() for the user's own Chrome (remote debugging on), .browser(isolated=True) for one of its own; it runs on the host, not in the sandbox |
| follow a procedure you wrote | .skill("/skills/<name>"), a directory holding a SKILL.md, on a volume mounted into the sandbox |
| keep notes on the user across sessions | .memory("./memory/user1"), a folder on this host whose MEMORY.md the agent writes with its memory tool and the system message shows as it was at build(); limit= bounds it in characters (3,000 by default). In a spec it is "memory": {"dir": ..., "limit": ...} |
| pick up an earlier conversation | .history(messages), e.g. a previous agent's agent.history |
| keep long runs within the context window | .context_manager(max_input_tokens=..., preserve_recent_turns=..., max_images=..., preserve_recent_images=...), which blanks old tool results past max_input_tokens (off unless given) and old screenshots past max_images (30, 0 for off) |
| think harder, or less | .thinking_effort("low" | "medium" | "high") |
| answer in a fixed shape | .output_schema({...}), a JSON schema |
A stdio MCP server runs on the host, with your program's access, not in the sandbox. Register only servers you trust. docs/content/guides/using-mcp.mdx has both transports in all three languages. docs/content/guides/using-browser.mdx has the browser's options and what it asks the user before letting the agent in.
async for output in agent.run("Create a bar chart of European populations and save it to /artifacts/population.png."):
for part in output["message"]["contents"]:
if part["type"] == "text":
print(part["text"])
run yields one complete message per step of the tool loop: the model's text, its tool calls in tool_calls, and each tool's result as a tool message. run_stream (runStream) yields deltas instead, for token-by-token output. A message is {"role", "contents": [parts]}; a part is text, image, function or value. To send an image, pass a whole message rather than a string. docs/content/guides/message-format.mdx has every field.
In Node, close the agent and the client in a finally. Closing the agent leaves the sandbox as it is, so one sandbox can serve several agents in turn; sandbox.remove() removes it.
Read the file back from the volume, not the model's last sentence: a turn that ends with "saved to /artifacts/population.png" and no population.png on the volume is the failure this step exists to catch. If the file is missing, the usual causes are an instruction that named no path, a volume the agent was not told about, or a sandbox made with network=False for a step that needed the network.
The examples in Ailoy's examples/ are small, each showing one thing in Rust, Python and Node, starting with hello: one turn, no tools, no sandbox. Fuller agents that use a sandbox (skills and data on volumes, artifacts handed back, the GPU, a browser) are in ailoy-examples, whose README lists them.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub brekkylab/ailoy --plugin ailoyOther plugins' skills for the same job