Skip to main content
Your process owns the conversation and the tool calls; the box only executes. Every BoxLite line below is identical whichever provider you call — for the opposite arrangement, where the agent CLI lives inside the box, see Run Claude Code.

When to use this


The contract

An agent loop that can touch a machine always has the same three moving parts. Only the middle one is BoxLite’s job:
  1. Tool declaration — a JSON Schema describing what the model may ask for. Provider-specific wrapper, identical schema.
  2. Tool implementation — runs the command in a Box and returns a plain dict. 100% provider-independent.
  3. Result feedback — hand the dict back to the model. Provider-specific plumbing.
So the page is organised the same way: step 1 is written once, step 2 is written per provider, and switching providers changes about ten lines.

Prerequisites

  • A working BoxLite install (Python boxlite or Node @boxlite-ai/boxlite) and a machine with hardware virtualization — see Installation.
  • Any model endpoint that supports tool / function calling, plus that provider’s client library. The examples show two protocols; the requirement is the capability, not the vendor.

Step 1 — The box side (identical for every provider)

This is the only BoxLite code in an agent loop. Copy it as-is; it does not change when you switch models.
Two behaviours above are worth internalising, because both are how an agent loop dies in production:

Step 2 — The model side (swappable)

Only this step is provider-specific. The schema from step 1 is reused verbatim; providers differ in how they wrap it and how tool results are fed back. === “OpenAI-compatible endpoints” Covers OpenAI itself and every gateway that speaks the same protocol — MiniMax, self-hosted vLLM, Ollama, and others. Switching among them means changing base_url and model, nothing else.
=== “Anthropic” Same schema, different wrapper key (input_schema instead of parameters) and an explicit message list instead of response chaining.
Why the first tab is the default in the full example below: the OpenAI-compatible protocol reaches the widest set of endpoints, including self-hosted ones — not because that provider is recommended. The only requirement BoxLite places on your model is that it supports tool calling.

Full example

Ties both steps together. To move to another provider, change the import on the marked line — nothing else.
Verified: the box side (sandbox_exec against a real python:slim Box) was run end to end, including the non-zero-exit and missing-command paths. The provider modules were checked against each SDK’s published call signature; the Anthropic tab was not exercised end to end here.

Parameters and returns

Only the BoxLite surface is listed — your provider SDK documents its own.

SimpleBox(...) — the options that matter in an agent loop

await box.exec(cmd, *args, ...) -> ExecResult


Troubleshooting

Box side

Loop side (any provider)


Running several agents at once

BoxLite ships orchestration primitives (BoxRuntime / ManagedBox) behind an extra:
Their API is still evolving, so this page does not restate signatures that may change. The runnable references are examples/python/07_advanced/multi_agent/ in the repository.