When does Tomosu Agent draft a fix?
Only for a finding whose rule has no safe template fix, or whose template does not fit this code, and only when you have turned model assist on. Rules whose safe fix would change logic, such as N+1 queries or cache stampedes, have written guidance only; those are the usual cases. A finding that already has a drop-in fix keeps it: the model may confirm or doubt the finding, but the template fix never changes.
What does a drafted fix look like?
In the console, the finding’s route reads Rule updated by Tomosu Agent and the change is headed Change drafted by Tomosu Agent. Here, the demo’s N+1 query is rewritten to fetch every order line in one query:

tomosu explain lists every step the agent took on it:
$ tomosu explain f-59b39e4aaf1c --engine http://localhost:7600
f-59b39e4aaf1c [Pre-merge + Runtime]
1. What matched
N+1 query detection (13.n-plus-one), category 13, version 1
app.py:97 in orders · demo/shop @ demo-1
call to db.cursor.execute with no keyword arguments
paired production signal R08.repeated-query-per-request fired on GET /orders → SELECT → sqlite
2. Runtime evidence
Same query repeated many times per request: GET /orders → SELECT → sqlite · active
demo / shop · version demo-1 · last 5m vs the 1h before
first seen 2026-11-27 02:10 UTC, last seen 02:14 UTC
calls 3192 · calls per request 21 · avg succeeded 0 ms · p50 1 ms · p99 1 ms · requests that repeated the call 100.0% · requests 152
3. How code and production were linked
http-route, confidence 90%: called while serving GET /orders; handler for GET /orders; matched to this code by function and kind of call
4. Why it matters
A database read runs once per loop iteration, so one request issues as many queries as there are rows.
One query per row slows pages as data grows.
5. Why this fix
Fetch all rows in one query before the loop (WHERE id = ANY(...), IN (...), select_related/prefetch_related or a join) and look them up in memory.
Behaviour change: The draft rewrites existing lines, not only adds code; review the behavior change.
6. Track record
No track record yet for this check (applied, kept and impact are collected once learning signals are on).
7. Ranking
Pre-merge + Runtime · weight 0.75 · strongest code link 90%
Priority scores (PRI) are not enabled.
8. Tomosu Agent (your own model)
Verified: Tomosu Agent agrees.
Step 1: validate: the model confirmed the finding
Step 2: draft attempt 1: verified (the file still parses; function names, parameters and decorators are unchanged; the check no longer matches the changed code)
Runs on: openai-compatible practice
How is a draft checked?
Exactly like a template fix: the file must still parse, every function keeps its name and parameters, and the rule must no longer match. A draft that fails is sent back with the reason, a bounded number of times; if none passes, the finding keeps its written guidance. A draft that rewrites existing lines, rather than only adding code, is marked as a behaviour change for you to review.
Drafts are always labeled AI-drafted and unverified until your build and tests run, and they are never applied without an Accept.
How do I ask for a draft from the terminal?
tomosu fix draft asks your model for a fix to one finding, prints the change and, with --out, writes a patch for you to apply:
export TOMOSU_MODELS_PROVIDER=anthropic TOMOSU_MODELS_MODEL=claude-sonnet-5-5 ANTHROPIC_API_KEY=…
tomosu fix draft f-59b39e4aaf1c --out draft.patch
git apply draft.patch # only after you have reviewed it
Here, with the demo’s practice model (recorded answers, so it needs no key):
$ tomosu fix draft f-59b39e4aaf1c --repo demo/shop --provider openai-compatible --base-url http://localhost:7700 --model practice asking on: openai-compatible, model practice, at http://localhost:7700 for a draft (only the function and the file's imports are sent, with likely secrets redacted)... AI-drafted fix for f-59b39e4aaf1c (N+1 query detection), by openai-compatible practice Unverified until your build and tests pass. Nothing has been applied. Proposal: this draft rewrites existing lines, not only adds code. Review the behavior change before using it. Checked: - the file still parses - function names, parameters and decorators are unchanged - the check no longer matches the changed code --- a/app.py +++ b/app.py @@ -93,9 +93,12 @@ def orders(): cur = db().cursor() result = [] + rows = cur.execute("SELECT id, customer FROM orders").fetchall() + lines_by_order = {} + for (order_id, sku, qty) in cur.execute("SELECT order_id, sku, qty FROM order_lines").fetchall(): + lines_by_order.setdefault(order_id, []).append((sku, qty)) + for (order_id, customer) in rows: + result.append({"id": order_id, "customer": customer, "lines": lines_by_order.get(order_id, [])}) - for (order_id, customer) in cur.execute("SELECT id, customer FROM orders").fetchall(): - lines = cur.execute("SELECT sku, qty FROM order_lines WHERE order_id = ?", (order_id,)).fetchall() - result.append({"id": order_id, "customer": customer, "lines": lines}) return result
fix accept on a finding with no drop-in fix does the same, and writes the draft only after you confirm (y at the prompt, or --yes once you have reviewed it). --no-model skips the model for one run. The call is time-boxed (--timeout, default 60 seconds).
What is sent to the model?
- the function that contains the finding, every line numbered;
- the file’s import lines;
- the rule’s name, risk and written guidance.
Literals that look like credentials are replaced with placeholders (<redacted:1>) before sending, and put back locally afterwards. Never sent: other functions or files, runtime evidence beyond a redacted summary, and any rule’s detection logic. Code goes only to the provider you chose, straight from your machine. With model assist off, nothing is sent anywhere.
Choosing a provider, budgets and memory are on Tomosu Agent.