One turn, not fifty
The program loops and filters at machine speed inside the sandbox. Only the final answer returns, so intermediate results never re-enter the model's context.
Turn your typed Go functions, protobuf RPCs or MCP tools into capabilities a model composes inside a sandbox. Fifty tasks become one model turn, and a registry decides what may actually run.
Three steps take the Go functions you already have to a model answering questions with them.
1. Define capabilities from typed functions. The structs are the schema; access is required, and writes can wait for a person.
source, err := gosource.New(
gosource.Func("orders.list", "Lists orders, optionally only those in one status.",
gosource.Public(), shop.List, gosource.ReadOnly()),
gosource.Func("orders.refund", "Refunds a paid order by ID.",
gosource.Roles("support"), shop.Refund, gosource.NeedsApproval()),
)2. Narrow to the caller, per request. What they may not call is withheld from the prompt and refused at run time.
mode, err := codemode.FromSource(source, capability.Caller{Roles: user.Roles})3. Run a request, and get a struct back.
revenue, result, err := agent.RunAs[Revenue](ctx, mode, model,
"how much have paid orders brought in?", agent.Options{Runner: runner})model comes from llm.NewFromEnv() and runner from sandbox.NewFromEnv(sandbox.Options{}). The Quickstart builds all of this as complete files in ten minutes. Already have protos or MCP servers? See Capability sources.
The model is asked once. Everything between the first call and the last happens inside the sandbox, and every capability call is checked against the registry before it reaches your code.
With no API keys and no database, the whole path still runs — search falls back to keyword ranking and a fixed program stands in for the model.
mise install
make demo-todoThen give a model the pen:
export ANTHROPIC_API_KEY=...
go run ./examples/todo -request "finish anything about docs"Or run the complete one — a task tracker with a web UI, SQLite storage, per-user scoping, and charts rendered from a prompt. It talks to any OpenAI-compatible endpoint:
go run ./examples/taskreport -serve :8080 \
-base-url https://api.deepseek.com/v1 -api-key sk-... -model deepseek-chatRead what code mode is for the idea, Architecture for how the pieces fit, or the flow for one request traced step by step.