A-02 Database Agent

81.5% right answers on 184 held-out questions, up from 48.4%
Questions about a music store, answered only through three read tools on a live SQLite server. A fifth of the albums, artists and customers in the test never appeared in training.
The base model wandered, calling more and more tools until it ran out of turns. Thirty steps of reinforcement learning took it from 48.4% to 81.5%, and taught it to commit to an answer.
Run it
Section titled “Run it”The weights are a LoRA adapter on top of Qwen/Qwen3.5-2B. Load both with transformers and peft.
-
Install
Terminal window pip install -U transformers peft accelerate -
Load and ask
run.py from transformers import AutoModelForCausalLM, AutoTokenizerfrom peft import PeftModelbase = "Qwen/Qwen3.5-2B"tok = AutoTokenizer.from_pretrained(base)model = AutoModelForCausalLM.from_pretrained(base, torch_dtype="auto", device_map="auto")model = PeftModel.from_pretrained(model, "superbird-labs/a-02-database-agent")SYSTEM = open("system_prompt.txt").read() # the prompt belowmessages = [{"role": "system", "content": SYSTEM},{"role": "user", "content": "your input here"}]ids = tok.apply_chat_template(messages, add_generation_prompt=True,enable_thinking=False, return_tensors="pt").to(model.device)out = model.generate(ids, max_new_tokens=512, do_sample=False)print(tok.decode(out[0][ids.shape[-1]:], skip_special_tokens=True))
The prompt
Section titled “The prompt”The exact system prompt is on the model card.
What it answers with
Section titled “What it answers with”list_tables() → describe_table("Track") → read_query("SELECT ...")"The album 'Big Ones' is 73 minutes long."Before and after
Section titled “Before and after”Real cases from the held-out set, never seen in training.
How long is the album 'Big Ones' in whole minutes, rounded down?
8 database calls. Out of turns. No answer.
Keeps searching and never answers.
4 database calls. "The album 'Big Ones' is 73 minutes long."
The right answer in half the calls.
How long is the album 'Faceless' in whole minutes, rounded down?
"216006 / 60 = 3600.1. Rounding down gives 3600 minutes."
The database counts in milliseconds. It divides by 60 and answers 3,600 minutes, sixty hours.
"The album 'Faceless' is 47 minutes long."
Reads the units right.
How many classical tracks are in the playlist 'Classical 101 - Next Steps'?
"There are 25 classical tracks in the playlist."
Off by one. The answer is 24.
"There are 24 classical tracks in the playlist."
Counts the right rows.
The recipe
Section titled “The recipe”| Base model | Qwen/Qwen3.5-2B |
| Method | GRPO with LoRA on the Surogate engine, multi-turn with real tools |
| Steps | 40 run, step 30 kept |
| Batch | 16 questions × 8 tries each |
| Turns | up to 8 tool calls |
| Hardware | one 48 GB L40S |
| Time | 55 minutes to step 30 |
The data
Section titled “The data”mcp-server-sqlite over the Chinook music-store database (MIT). 925 questions to train on, 184 held out. 20% of the names in the held-out set never appear in training.
The reward
Section titled “The reward”1 for the right final answer (numbers to the cent, names ignoring case and spacing). A list of guesses scores 0.
Train it yourself
Section titled “Train it yourself”Trained with the open-source Surogate engine (1.5.17 or later), kit mcp. Full kit notes: Surogate mcp kit.
CUDA_VISIBLE_DEVICES=0 surogate grpo-colocate \ --train examples/kits/mcp/train.yaml \ --infer examples/kits/mcp/infer.yaml \ --orch examples/kits/mcp/orch.yamlThe held-out score shows in the log as Avg@1= and the adapter lands in outputs/kits/mcp/. To point it at your data, read Retrain on your data.
The scores
Section titled “The scores”Right answers on 184 held-out questions. Tool calls per question fell from 5.8 to 4.7, and running out of turns fell from 68 questions to 14. One run, one seed.
Where it fails
Section titled “Where it fails”- Score the skill, not the format. The first reward paid only for answer tags and scored the base model at 0% while it was finding most answers. The honest baseline is 48.4%.
- A constant learning rate of 1e-4 made it call more and more tools until it ran out of turns. Half the rate with cosine decay held.
- Checked outside the training run: 52.7% to 89.1%, 67 answers fixed, none broken.
Where it fits
Section titled “Where it fits”- Ask your own database in plain words. Point it at an MCP server over your data (SQLite, Postgres, an internal API) and retrain on your questions.
- Analytics that shows its work. Every answer comes from tool calls you can log and replay, not from memory.
- A template for agent training. A clean way to see reinforcement learning teach a small model to stop exploring and commit.

Open small models for every industry, free to run offline. Custom ones for companies.
superbirdlabs.com Custom models Hugging Face hello@superbirdlabs.com