Skip to content

Errors

Ailoy raises two kinds of error: errors from Ailoy itself (a model that isn’t set up, an unregistered tool, an API error), and errors from the sandbox, which come from virtx.

Language Ailoy’s errors Sandbox errors
Python ailoy.AiloyError (a subclass of Exception) virtx.VirtxError, with the server’s status
Node.js Error with code set to "AILOY_ERROR" Error with code set to "VIRTX_ERROR"
Rust anyhow::Error anyhow::Error

An invalid argument, such as calling build() twice on the same builder or passing a function that isn’t callable as a tool, raises ValueError in Python and an Error with code set to "INVALID_ARG" in Node.js. These are mistakes in your code, so fix the call; retrying won’t help.

In Node.js, calls on the virtx package itself, such as createSandbox, throw virtx’s own VirtxError, with source and status. See virtx’s errors reference.

from ailoy import AiloyError
from virtx import VirtxError
try:
async for output in agent.run("Summarize /data/report.txt"):
...
except VirtxError as e:
print("sandbox failed:", e.status, e)
except AiloyError as e:
print("agent failed:", e)

Automatic retries

Backends that call an HTTP API (api, bedrock, openrouter and self-hosted) retry a request up to 3 times when the server answers with status 429, 500, 502, 503, 504 or 529. Gemini’s API (google on api) retries the same statuses except 429. Between attempts they wait for the time in the server’s Retry-After header, or 1, 2 and then 4 seconds, at most 10 seconds. Each retry is logged as a warning (see Logging). If the last attempt fails, the error is raised. Retries can’t be configured.

The cli backend doesn’t retry: an error from the CLI is raised as it is.

Logging

Ailoy writes log messages, such as a warning for each retry, through Rust’s log crate.

  • Python and Node.js: the packages don’t pass these messages on, so nothing is printed. Errors still reach your code as exceptions.
  • Rust: install a logger in your program to see them, such as env_logger, and run with RUST_LOG=ailoy=warn.
fn main() {
env_logger::init();
// ...
}

Refused requests

In Rust, when a model’s API rejects the request itself, with a 4xx that isn’t about load or credentials, the error is an ailoy::model::RequestRefused. Sending the same request again won’t help; what’s in it has to change. Find it with err.downcast_ref::<RequestRefused>(), which has the status and message.

When errors are raised

When Common causes Guide
AgentBuilder.build() The org has no backend; an API key isn’t set; a skill’s SKILL.md is missing or invalid; conflicting browser options. Model providers troubleshooting, Skills troubleshooting
The first turn The CLI isn’t installed or logged in; the model server isn’t reachable. Model providers troubleshooting
During a turn The model fails before replying; the reply is cut off at the output limit; the API rejects an image twice. Handle errors
Reading history or calling start_browser during a turn Python and Node.js only allow these between turns. Agent
Using an agent after close() The agent has been closed. Agent
register_mcp_stdio The command isn’t installed, or the server exited at startup. MCP troubleshooting
Creating a sandbox The machine can’t run a VM, or the image doesn’t exist. Installation troubleshooting, Sandbox troubleshooting

A tool that fails during a turn doesn’t raise. Its error becomes the tool’s result, and the model can try something else.