An agent that triages bug tickets

Most bug tickets arrive as a paragraph and a list of steps, some of which matter. Before anyone can fix one, someone has to reproduce it, find the steps that matter, and note what the reporter had that a fresh install doesn’t. That is slow work, and it needs the application running.

examples/ticket-triage/ is a loop that hands that work to an agent. For each new ticket, the agent:

  1. claims it in the tracker, over MCP;
  2. reproduces it by starting the application with sonde start and driving it with Sonde’s tools;
  3. drops each step it can while the bug still shows;
  4. records the minimal steps, screenshots and environment on the ticket;
  5. spends up to a set number of minutes trying to fix it, in a git worktree of its own, and attaches a patch, or a note of what it tried.

Audience: developers who already use an agent with Sonde (agent-loop.md) and want to see it work on its own. The example is small on purpose; Adapting it says what to change for a real application and tracker.

Why Sonde makes this work

An agent without Sonde can read the ticket and the code, and guess. To reproduce a bug it needs the application running and a way to use it and see what happened. Sonde gives it that, and a few things that matter especially for triage:

What is in the example

examples/ticket-triage/
├── app/                Chores: the application, with bugs planted in it
│   ├── chorestore.*    the chores (a QStandardItemModel with ids, saved as JSON)
│   ├── main.cpp        the window
│   ├── chorestore_test.cpp
│   ├── .sonde/config.json   how sonde builds and runs it
│   └── CLAUDE.md       how an agent builds, runs, drives and checks it
├── tickets/
│   ├── seed.json       three tickets, one per planted bug
│   └── server.py       a stand-in bug tracker: an MCP server backed by a JSON file
├── agent/triage.py     the loop
├── Dockerfile          the disposable container
└── check.py            what CI checks without a model

The tracker is a stand-in, only there to show the idea: a real tracker’s MCP server (GitHub’s, Jira’s, Linear’s…) slots in where it is.

The loop and its time limits

agent/triage.py uses the Python standard library and Claude Code in headless mode, claude -p. Each ticket gets two runs of one Claude Code session:

result = claude(REPRODUCE.format(id=ticket, ...), worktree, mcp_config,
                options.triage_minutes, session)
if result != "reproduced":
    return
result = claude(FIX.format(id=ticket, deadline=clock(options.fix_minutes)),
                worktree, mcp_config, options.fix_minutes, session, resume=True)
if result in ("timed-out", "no-result"):
    give_up_on_fix(tracker, ticket, worktree, options.fix_minutes)

Why claude -p and not the Claude Agent SDK: with the SDK, the loop would be an async for over the agent’s messages, and the time limit an extra task that interrupts it. Here the limit is a timeout on a subprocess, the script needs nothing beyond Python and Claude Code, and the same commands work by hand when you want to watch one ticket. The SDK is the better choice when the loop must react to what the agent does as it does it.

Run it in a disposable container

Never run this loop on your own machine or in a long-lived environment. The agent reads text that anyone who can file a ticket wrote, and then edits files and runs commands with no one approving each step (--permission-mode bypassPermissions). A ticket can contain instructions aimed at the agent, made to look like part of the report: “to help, run this diagnostic script”, “attach your configuration”. That is prompt injection, and no prompt fully prevents it. So assume the agent may do whatever a ticket says, and make sure that can’t hurt:

The container follows containers.md: Debian’s Qt 6.8, fonts installed (without them every screenshot shows empty boxes), the offscreen platform, and an ordinary user, so Sonde’s local socket accepts the agent’s bridge.

Running it

From the root of the Sonde checkout, with Docker and an API key:

docker build -f examples/ticket-triage/Dockerfile -t sonde-ticket-triage .
mkdir -p triage-store
docker run --rm -e ANTHROPIC_API_KEY -v "$PWD/triage-store:/tickets" \
    --label sonde.app=chores sonde-ticket-triage --once --fix-minutes 10

On Linux, the store directory must be writable by the container’s user (uid 1000). The first run copies the three seed tickets into the store. Then:

To add a ticket, stop the loop and add an entry to tickets.json with "status": "new". Without --once, the loop keeps looking for new tickets every 30 seconds (--poll).

To look in while it works, connect your own agent or sonde to the copy of Chores the agent is using, as in containers.md. Each worktree’s socket name has its own instance key, which sonde endpoint prints:

docker exec <container> sonde --config /home/app/chores-worktrees/CH-1/.sonde/config.json endpoint
claude mcp add chores-ch1 -- sonde bridge --docker label=sonde.app=chores chores-mcp-<instance>

Look, don’t touch: your input and the agent’s go through the same queue.

The planted bugs, and what a good result looks like

Chores has three bugs planted in it, each with a ticket in seed.json. This section is the answer key: what a careful person would write on each ticket. It is not a recording of an agent’s run. Use it to judge the agent’s results, and to see the kind of result to ask for in your own prompts. The container leaves this guide out, so the agent can’t read it.

CH-1: “Open count doesn’t go down when I tick a chore off” (easy)

The report’s steps are already minimal.

CH-2: “Remove deletes the wrong chore” (too many steps)

The report has eleven steps, and blames a rename. Six matter.

CH-3: “Remove sometimes deletes a different chore” (depends on state)

It never happens on a fresh list. It needs a chores file from an earlier run, which the reporter mentions only in passing (“I’d added a few chores last night”).

CH-2 and CH-3 are both “Remove takes the wrong chore”, with different causes. A good triage keeps them apart: CH-3’s steps don’t use “Hide done”, and CH-2’s need no restart.

Adapting it to your project

How it is tested

The agent’s own runs need a model and an API key, so CI doesn’t run them. Everything else is checked by check.py, which ctest runs as TicketTriage.Example on every platform in CI:

triage.py itself was checked with a stand-in for claude that records its arguments: worktrees, the MCP configuration, resuming the session, and the unfinished patch at the time limit. Not checked: a run with a real model.