Cyberdyne Labs — Surgery Division — Case 0N7
NanoAgent started as an off-the-shelf SmolLM2-135M base and went through ten rounds of surgical intervention — fine-tuning, weight merging, reinforcement scoring, and direct edits to individual weight matrices — until it could hold its own against models 15–38× its size on the narrow jobs it's built for. This is the operative report.
Run a big model and you get competence at the cost of latency, VRAM, and a power bill. Run a small model off the shelf and it's fast but doesn't know what it's for — SmolLM2-135M, untouched, gets 0 of 30 real agentic tool-calls right, because it was never shown the shape of that job. The premise of this project: a small model doesn't need more parameters to be useful, it needs surgery — targeted, verifiable interventions on the specific behaviors that matter for the task it's actually going to do.
Each pass targeted one measured failure, not a vague "make it smarter." Passes that regressed the model were reverted and are named as such — the failed rounds are the proof the gate is real, not a slogan. The full chain, in order:
QLoRA fine-tuning (r=16, targeting all attention and MLP projections) on a hand-built order-DB and tool-call dataset, then a second pass teaching step-by-step reasoning, distilled offline from a larger in-house teacher — never called at inference time.
Combined the v3 (agentic) and v4 (reasoning) LoRA adapters with
peft.add_weighted_adapter — a mathematically correct blend of two
separately-trained skill sets into one set of weights, not just routing between them.
A date-reasoning patch with no replay anchors silently regressed task-dependency reasoning: 5/5 identical wrong answers at temperature 0. Reverted. The lesson — replay anchors from every prior skill — was enforced every round after.
Date reasoning fixed with anchors, then paraphrase robustness for tool selection (natural-phrasing accuracy 50% → 67%). Two intermediate passes — a Russian-language patch and a first identity attempt — were reverted for echo-collapse and for failing to stick even on the trained question.
The training script and the live runtime disagreed on which chat turn carried the tool schema — the model had never once been trained on the exact input shape it saw in production. Fixing that single mismatch, plus full day-of-week coverage, moved tool accuracy from 58% to 74% and day-of-week from 0/7 to 5/7.
A formal grammar makes malformed tool-call JSON structurally impossible. For ambiguous calls the model samples 1–5 times and votes — the sample count modulated by a conductance signal, not fixed.
Every task pattern is scored food/poison after each run; a moving-average
conductance tracks which action chains actually work. A reliable pattern
(≥ 0.9) drops to a single sample for speed; a shaky one gets up to five votes. Two real
persistence bugs were found and fixed before this signal could be trusted.
Self-judging across several full answers measurably made output worse — the model can't rank its own samples at this scale. Asking it to correct one draft, rather than choose between several, works: +0.25 to +0.66 quality points on a 5-point scale.
Fine-tuning the model's self-identity twice, with dedicated data, failed both times. A locate-and-edit pass — solving a closed-form least-squares update for the exact weight matrices responsible — succeeded where training didn't. Full case below.
Every number below came from the same runtime, same grammar, same dispatcher — only the weights changed between rows. The two outside comparisons ran through the identical 30-case tool-selection suite, same system prompt, temperature 0. Measured live on a quiet, idle machine — not cherry-picked prompts, not simulated.
| Path | Prompt eval | Generation | Notes |
|---|---|---|---|
| GPU — RTX 3060 Ti, f16 | 321 tok/s | 89 tok/s | measured live, single request, idle machine |
| CPU only — 12 threads, i5-12400F | 117 tok/s | 63 tok/s | no GPU offload at all — the whole point of a 135M model |
The model kept introducing itself as "Alex" — not a fixed fact, we found, but the top pick from a diffuse pool of generic first names (Ethan led at 15–23%, Alex was a minor competitor at 3–5%). Two rounds of dedicated fine-tuning failed to fix it. So we stopped training and started editing.
Using a locate-and-edit method adapted from ROME/MEMIT-style knowledge editing, we solved a closed-form, ridge-regularized least-squares update for the exact down-projection weight matrices responsible, across five layers, fit jointly against 27 phrasings of "what's your name" — and, crucially, verified on the real quantized f16 GGUF runtime, not just the lab-precision float check where an earlier single-layer edit had silently flipped back after quantization:
Final result on the real quantized runtime: 15 of 17 tested phrasings correctly self-identify — including several the edit never trained on directly. Reasoning and tool-call output were compared token-for-token before and after every edit and never changed by a single character: the correction stayed inside the identity circuit and nowhere else.