AI Agent Bugfix

An agent that debugs and fixes a failing test on its own, then gets independently verified.

Intermediate~10 minAlineo.load()agent.prompt()agent.bash()

An AI agent that debugs a failing test and fixes the bug itself — inside its own sandbox, using nothing but bash and a model.

Setup

Start OpenSandbox in Docker (one-time setup):

bunx alineo-cli init

Get a free API key from build.nvidia.com and export it:

export NVIDIA_API_KEY=...

Run it

cookbooks/ai-agent-bugfix
$bun install
$bun start
Simulated preview — no sandbox is actually created here.Run it for real →

What it does

Plants a deliberate off-by-one bug in calc.py and a test that catches it.

Runs pytest via agent.bash() to show the failure.

Prompts the agent — via alineo's Alineo.load() + agent.prompt() — to find and fix the bug itself, streaming its reasoning and tool calls as they happen.

Re-runs pytest independently of the agent (via agent.sandbox.exec()) to verify the fix, rather than trusting the agent's own claim that it passed.

agents/bugfix-agent.json configures a Pi agent on python:3.11-slim using the NVIDIA NIM API. Swap provider/model for anything in @alineo-labs/model-providers to use a different key.

Never trust the agent's self-report

Step 4 is the important part of this recipe: never trust an agent's self-report that a fix worked — re-run the check yourself against the sandbox it was working in.

Where to go next

See the Agent SDK docs for the full alineo API (prompt, bash, steer, fork, model switching, and more), and examples/pi-agent for a tour of every command it exposes.