Taming Small Models That Don't Speak Your Tool Protocol

September 2026 · 16 min read

When I wrote about Atlas in July, it ran one family of models: Gemma, on Google's LiteRT-LM runtime. The whole app had been shaped around how Gemma behaves. It emits tool calls in the JSON field the runtime expects, it tolerates every sampling option I attach, and it stays quiet about its reasoning unless asked. In early September I added a second family, Liquid AI's LFM2.5, in a 1.2B and a 2.6B size, converted to the .litertlm format by the LiteRT community. They are small and fast, and on paper they were a drop-in addition: same runtime, same file format, a new row in the model manifest.

In practice almost every assumption I had baked in turned out to be a Gemma assumption. This post is the list of things that broke, roughly in the order I found them, and what each one taught me about running models you didn't train on a runtime you didn't write.

Atlas series

  1. Fitting a Second Brain Into 8,192 Tokens (the July original)
  2. Taming Small Models That Don't Speak Your Tool Protocol
  3. Retrieve, Then Generate: Closing the Speed Gap on a Phone
  4. Letting the Network In Without Letting the Data Out
  5. Ears and Eyes on a Phone: Voice and Vision in Atlas
  6. The Experiments I Didn't Ship
  7. Atlas, July to November

A crash with a convincing wrong explanation

The first LFM2.5 generation died in native code with INVALID_ARGUMENT "Logits dimensions must be [batch_size, 1, vocab_size]". Nothing on the Swift side could catch it. The error mentions tensor shapes, so I went looking for a shape problem, and I found a very plausible one. The manifest pointed at a CPU-flavoured _int4 export while Atlas's warmup tries the GPU first, and there is a real upstream issue (LiteRT-LM #3129) about prefill signatures on iOS Metal. I swapped in the _int4_gpu export, added a CPU-only flag for the iPhone, and felt clever.

The crash was still there. It reproduced on LiteRT-LM v0.15 and v0.16, on the GPU and on the CPU, with a 1,024-token window and with 4,096. When a native crash survives every change to the backend, the window and the runtime version, the engine configuration is probably innocent. What's left is whatever the app sends per message.

The way I proved it was to take Atlas out of the picture. The upstream litert-lm command-line tool loaded the identical file and generated cleanly on every backend and window where Atlas failed. So the bundle and the runtime were fine, and the difference had to be in the per-send options Atlas attaches. One of those is a mild repetition penalty of 1.1, which I had wired in during August to damp the token loops small models fall into. I had A/B tested it on Gemma E2B and it didn't hurt grounding (0.56 with it, 0.57 without). The upstream CLI never sets one. With the penalty disabled, all four real-model smoke tests passed.

The fix is one manifest flag, disableRepetitionPenalty, set on both LFM2.5 entries and honoured even when the environment override asks for a penalty. I kept the GPU-export change too, because it fixed a real problem. It just wasn't this problem. The lesson I wrote into the project notes is about method: when a native crash ignores every engine-level change, diff your per-send arguments against the most minimal client that works, and don't accept the first theory that happens to have a real issue number attached.

Tool calls that arrive as prose

The next problem was quieter and much more important. Atlas's tools (search the knowledge base, check the calendar, create a reminder) run inside LiteRT-LM's native agent loop. I had believed that loop was grammar-enforced. Reading the runtime source showed otherwise: it parses the model's free-form output looking for a structured tool_calls JSON field. Gemma is trained to fill that field. LFM2.5 is trained to write its calls in its own syntax, a Python-style bracket like [search_knowledge(query="dentist")], sometimes wrapped in <|tool_call_start|> and <|tool_call_end|> tokens.

So the runtime never saw a call. The bracket text streamed into the chat bubble, nothing was searched, and the model carried on to answer from nothing. On my tool-call eval, LFM2.5 1.2B scored a tool recall of 0.00 in both its Instruct and Thinking variants. I ran a Gemma control through the identical pipeline at 4,096 and 8,192 tokens to rule out the window. The mismatch was between the model family and the runtime's tool protocol, and no prompt was going to fix it.

My first design was ambitious: wrap every agent response in a JSON envelope enforced by LiteRT-LM's constrained-decoding option, so any model from any vendor would be forced into one format. Then I measured that option on the version I ship, and it was a no-op. Output was byte-identical with and without the constraint, on LFM2.5 and on Gemma. A design that depends on a decoder guarantee the decoder doesn't actually give is a design built on sand, so I went the other way and taught Atlas to recognise the model's own dialect.

The recovery has four steps. While the answer streams, Atlas asks one question about the text so far: could this still turn into a leaked call? If the first chunk is Your appointment, the answer is no, and the text streams live as it always did. If it starts with [ or a tool-call token, Atlas holds the text back and shows nothing yet. When the stream ends, parseLeakedToolCall turns the bracket syntax into a real ToolCall. That call goes through ToolRegistry.execute, the same choke point every native call uses, so a reminder or calendar event still needs the user's confirmation and the model can't approve its own action. Finally, the tool result is sent back as a continuation on the same warm conversation, so the KV cache is reused and the follow-up costs one short prefill.

Streamtokens arrive Hold backcould be a leak Parse[name(args)] ToolRegistryexecute + confirm Continuesame warm cache

What the model emits

What the chat shows

Leaked-call recovery, replayed. Orange text is held back and never painted. An ordinary answer fails the prefix check on its first chunk and streams live. The example question and note are made up.

Each of those steps had a bug in its first version, and each bug was found by watching the real model on the real app. The hold-back check initially held any answer that began with [ for the entire turn, so a reply opening with a Markdown link or a bracketed aside never streamed at all. It now validates the text incrementally against the bracket-call shape and lets go as soon as the shape is impossible. Then LFM2.5 1.2B turned out to narrate on the same line as its call, [create_reminder(…)]Creating a reminder…, and the first version released the buffer the moment anything followed )]. The call streamed into the bubble as prose and was never executed. A complete call now keeps holding whatever follows it. On the MLX runtime (more on that below) the detokenizer can hand back a single < as the first chunk after the model's reasoning, which didn't look like the start of <|tool_call_start|> to a check that only knew the whole literal, so streaming latched live and the markers leaked. The check now accepts any valid prefix of the marker.

Two design choices matter more than the parsing. The first is the round limit. A recovered call can produce a follow-up that is itself a leaked call, such as looking up a person and then their calendar, so the loop allows up to three rounds per turn. Each round must answer a new call, and a repeat stops it. When a round can't be recovered, the last reply is stripped of call syntax and shown, and it is never executed. Every round lands in LFM2.5's 4,096-token cache, so the cap is tight on purpose. It's a bounded tool loop and nothing like a retry, which matters because Atlas has an invariant against silent retries.

The second is how a recovered exchange is stored. LFM2.5's own chat template has a bug where it mangles tool_calls and empty content fields when it rebuilds its history. So Atlas persists the recovered call and result as an ordinary tool message rendered as plain [Tool result: …] text. On a cold rebuild the model sees readable text, and nothing shaped like native tool-call JSON ever reaches the broken template path.

It works, with honest limits. On the per-model smoke matrix, 2 of 6 sampled 1.2B runs leaked their call and both were recovered. The 1.2B still almost never calls an act-tool on its own. Asked to create a reminder, it replies "please confirm so I can create it" and waits, which is a polite way of scoring zero on action recall. The 2.6B passes every probe in the matrix, alongside all three Gemma bundles. The small one is useful anyway, because Atlas retrieves before it generates and puts the excerpts in front of the model whether it asks for them or not. That design is the subject of the next post.

Reasoning needs a budget

LFM2.5 ships in Instruct and Thinking checkpoints. The Thinking ones emitted nothing at all in Atlas: no reasoning, no answer, an empty bubble. They need LiteRT-LM's native ThinkingConfig attached to every send, and once it is, the reasoning doesn't arrive as inline <think> tags the way some models do it. It streams on a separate native "thought" channel, which my tag-based splitter couldn't see. Atlas now reads that channel directly into a collapsible reasoning row.

The config also needs a token budget. Unbounded, a small model can reason until it has filled a 4,096-token window and never write an answer. A week later the same class of bug hit Gemma on a 6 GB iPhone, where every question got "No answer was generated." The Gemma manifest entries prepended Gemma's think token to the system prompt, which switches reasoning on, but didn't attach the native config, which is where the budget lives. So reasoning ran unbounded every turn. Since then the two flags are checked as a pair by a manifest test that runs in CI without any model on disk.

The error message turned out to be a diagnostic. Atlas says "ran out of thinking budget" only when reasoning streamed and the answer channel never fired. If the user sees the generic "No answer was generated" instead, the stream produced no events at all, and that points at a missing or wrong native config rather than a model that thought too long.

Even a bounded budget can be wrong. I raised the LFM2.5 Thinking budget from 512 to 1,024 tokens, which on iOS Metal equalled the whole 1,024-token GPU window and brought back the empty turns. The fix was to stop trusting the manifest number on its own. effectiveThinkingBudget clamps it to half of the window the engine actually opened with, and re-applies the clamp when the window has to degrade, so an answer always has room.

A bigger window that produced nothing

My development Mac has 48 GB of memory, and LFM2.5 was capped at a 4,096-token window while Gemma got 8,192 on the same machine. The obvious experiment was to give LFM2.5 2.6B the bigger window on macOS. In LiteRT-LM the window is a runtime knob that sizes the KV cache, so nothing about the exported graph stops you. It built, the full 1,190-test suite passed, and the engine came up without complaint.

Then I ran the real groundedness smoke test against the real bundle at 8,192 tokens, and every turn came back empty.

What the logs said was fine Engine creationcreatedok Time to first token~1.7 sok Decode speed~77 tok/sok Answer characters per turn, window 8,192 Each dashed outline is room for an answer. Each turn wrote 0 / 11 turns answered
The rejected 8,192-token experiment on LFM2.5 2.6B: normal-looking speed metrics and zero characters on all 11 turns of the smoke test.

The model was never trained on positions past 4,096. Running past its trained length didn't make it a bit worse. It made it fail silently on every turn while the speed metrics looked healthy. I reverted the change and left a comment on the manifest's maxContextTokens field with the evidence (agent.turn.chars: 0, 11 of 11 turns), so the next person who has a big Mac and the same idea doesn't have to rediscover it. For this family the fix for running out of room is shorter history inside 4,096, not a bigger window.

That experiment is also why the manifest carries per-model limits now. Before LFM2.5, the window was purely a function of device memory: 8,192 on a 16 GB machine, less on smaller ones. On a high-memory device Atlas had been asking LFM2.5 for a KV cache bigger than the bundle supports. Each entry now has its own ceiling, and memory tiers can only lower it.

The bug my desk can't reproduce

Adding a second family also flushed out a Gemma bug. On my iPhone 14 Pro, every Gemma bundle (E2B, E4B and 12B) started replying with nothing but <pad> tokens. On macOS it never happened, across five different prompt shapes. The file hashes matched the manifest, and nothing in Atlas's Swift code produces or mentions <pad>, so it was coming out of the native decoder.

The reason the Mac can't reproduce it is buried in a log line. On macOS the runtime can't load its WebGPU sampler library and quietly falls back to a sampler written against the C API. My Mac never runs the sampler the iPhone uses. The leading suspect is speculative decoding: only Gemma 4 ships a multi-token-prediction drafter, and a bad speculative draw surfacing as a raw vocabulary token would match a symptom that tracks the Gemma family exactly. I added two environment switches to bisect it on the device, one to turn the drafter off and one to turn constrained decoding off. I also added a defensive strip, so the bug now shows "No answer was generated" instead of painting a bubble full of padding. As I write this it is still open, and it's the reason I now treat "works on my Mac" as weak evidence for anything that touches the GPU.

A second runtime for the iPhone

The 2.6B is the LFM2.5 that answers well, and on iPhone it couldn't use the GPU. iOS Metal fails at engine creation for that bundle: the delegate can't lower the hybrid model's convolution-state operations, the same family of problem as #3129, and nothing in the app can change that. The CPU fallback works, but its cold start is the slowest in the whole manifest.

So Atlas got a second on-device runtime. Apple's MLX runs Liquid's own 4-bit MLX export of the 2.6B, a single 1.58 GB file, directly on the iPhone's GPU. On my Mac it decodes at about 77 tokens per second with about two seconds to the first token. MLX meant a new MLXService behind the same backend protocol, with the same rules: warm KV-cache reuse per conversation, one choke point for tools, and the same leaked-call recovery, because LFM2.5's MLX checkpoint leaks its calls exactly the way the LiteRT one does. I moved the shared parsing into one file so both backends run the same code.

MLX also taught me what jetsam feels like. Downloading the MLX 2.6B on a phone killed the app at exactly 100%, with no logs at all. Finishing a download auto-selects the new model, which warms it immediately, and MLX holds its weights fully resident in unified memory. On a phone that's too small, that is an out-of-memory kill by the OS, with no Swift error to catch and nothing written anywhere. None of the MLX entries had a memory floor. They have one now (3 GiB for the 1.2B, 5 GiB for the 2.6B and 24 GiB for the 8B), and a test fails if any future MLX entry ships without one. The phone-sized 4-bit variant asks for 4 GiB.

I nearly set the 2.6B's floor at 7 GiB, which would have excluded every 6 GB iPhone. That number assumed the KV cache rivals the weights. LFM2 is a hybrid, though: only 8 of its 30 layers are attention layers, and the other 22 are convolutions with a three-element cache. At 8 KV heads of 64 dimensions, the cache is 128 MiB at 8,192 tokens against 2.67 GiB of weights. Working the arithmetic out from the architecture was worth a whole device class.

One more MLX lesson arrived during a long eval run. MLX keeps a buffer-recycling cache whose default limit is close to all of the GPU's working memory. Atlas never bounded it, so memory grew turn after turn until the OS killed the process about 47 turns in, on a 48 GB Mac. On a phone that would be a jetsam kill in the middle of a chat. One line at warmup sets the cache limit to 64 MiB, which follows MLX's own guidance for iOS.

The quirks, in one table

SymptomModelCauseFix
Native crash, logits shapeLFM2.5Repetition penalty in per-send optionsdisableRepetitionPenalty
Tool call shown as textLFM2.5Own bracket syntax, no tool_calls fieldHold back, parse, execute, continue
Empty bubbleLFM2.5 ThinkingNo ThinkingConfig attachedAttach it, with a budget
"No answer was generated"Gemma 4 on iPhoneThink token without a budgetFlags checked as a pair
Empty turns on iOSLFM2.5 ThinkingBudget equal to the GPU windowClamp to half the live window
Zero characters, every turnLFM2.5 at 8,192Past trained context lengthReverted, comment in manifest
<pad> repliesGemma 4 on iPhoneSuspected speculative drafterOpen; bisect switches + strip
Killed at 100% downloadMLX 2.6BNo memory floor, instant warmupPer-entry RAM gate + test

Update, late October

LFM3 1.7B arrived on October 27, and the work above paid off quickly. A community LiteRT conversion loads on the runtime version I pin. It tolerates the repetition penalty that crashes LFM2.5, it thinks by default (without a budget, one follow-up took 352 seconds and produced no answer), and it leaks its tool calls as XML instead of brackets. Supporting the XML shape was one more parser behind the same recovery path. Later I also made the round cap adaptive: when the prefetched excerpts are already confident, one extra search is allowed instead of three, because LFM3 otherwise spent every round on a new paraphrase of the same question at roughly eight seconds of reasoning each.

What I'd tell myself in August

A model's file format being supported by your runtime says very little about whether the model speaks the runtime's protocol. Tool calling, reasoning output and sampling options are all places where a model family's training meets a runtime's assumptions, and each one failed differently: one crashed, one leaked text, one went silent.

When something is wrong, the most useful thing to have is a minimal client that works. The upstream CLI found the repetition-penalty crash in an afternoon after a day of my own theories. A per-model smoke matrix (a plain answer, a thinking probe and a real act-tool call for every bundle in the manifest, about two minutes for five models) now runs before any model change ships, and it's the only reason I trust the table above.

And the limits a model was trained with are part of its contract, even when the runtime will happily let you exceed them. The window experiment didn't produce slightly worse answers that I could have weighed against longer conversations. It produced none, while every metric I was watching looked normal.

Try Atlas

Get Atlas for iPhone & iPad or get Atlas for Mac on the App Store.

References