Why local LLM agents stall, empty turns and cut tool calls

Why local LLM agents stall, empty turns and cut tool calls

A coding agent running on a local model has a failure mode that looks like stupidity and usually is not. The agent reads a file, thinks, and then nothing happens: an empty reply, a retry, another empty reply, a crash with an HTTP 500, or a run that ends on a turn limit while the tests were already green. When I first saw this on my bench I filed it as the model failing the task. Most of the time I was wrong. Across the five models I ran in the definitive campaign on an RTX 5060 Ti with 16GB of VRAM, the episodes that stalled had mechanical causes, and in most of them the culprit was the loop around the model. What follows is the checklist I now run before blaming a model for a stall. Each item lists the signature it leaves in the logs and the number I got on my own hardware.

The measurements come from 1,488 agent turns across five models: Qwen3.8-27B in the GSQ-RCO quantization with MTP, the same 27B in uniform IQ4_XS, Ornith-1.5-35B-A3B, Ornith-1.5-9B and NeoHorse-1-9B, the last two at Q8_0. All five ran with reasoning on, a 6,000-token cap on every turn, and a 65,536-token context, inside an agent loop that mirrors the one I ship in a VS Code extension.

Note

The bench: RTX 5060 Ti 16GB (Blackwell, 180 W limit) on PCIe Gen3 x8, Ryzen 5 4500 with 6 cores, 32GB of DDR4 at 3,600 MT/s, Debian 13, NVIDIA driver 615.71.09 with CUDA 13.4, llama.cpp at commit 391fac1 with --fit off, a q4_0 KV cache and one slot, sampling at temperature 0.4 with a fixed seed per task and repetition. All the numbers you see here come from the benchmark procedure described in detail in how my harness runs agent tasks and the hidden oracle; the Strata run mentioned below was a session outside the harness.

What does a stalled agent look like from the outside?

From the outside, every stall looks alike: the agent stops emitting tool calls that do anything. In the logs they split into four shapes, each with a separate fix. I list them in the order I found them, which is close to the order of how often they happened.

Signature in the logsWhat happenedWhose fault
Reply with no content and no tool call, finish_reason=lengthReasoning used the whole turn budgetThe token cap, set by the loop
HTTP 500 on the request after a length turnA tool call cut mid-argument was echoed back to the serverThe loop, which resent a broken call
Run ends on max_turns or wall clock with tests greenThe ceiling fits a faster modelThe ceiling, not the model
Prompt grows toward the context limitTool outputs piling up in historyNobody yet: watch it

If you build or operate coding agents and want the same instrumentation in your own pipeline, my hub on AI for software development covers how I work on it.

1. Check for empty turns before anything else

Empty turns are the most frequent stall. A reasoning model gets the conversation, starts thinking, and doesn't stop until it hits the maximum number of tokens allowed for that turn. The server closes the reply with finish_reason=length. Reasoning fills its channel, the content field is empty, and there are no tool calls. From the loop's point of view the model has said nothing.

On my bench this happened on 6% to 15% of all turns, depending on the model, with a cap of 6,000 tokens per turn.

Share of agent turns that hit the 6,000-token cap with reasoning onvalues in %
Share of agent turns that hit the 6,000-token cap with reasoning on
ModelTurns at the cap (%)
Qwen3.8-27B IQ4_XS (37 of 241)15.4
Ornith-1.5-35B-A3B (36 of 269)13.4
Qwen3.8-27B GSQ-RCO (28 of 243)11.5
Ornith-1.5-9B (49 of 479)10.2
NeoHorse-1-9B (16 of 256)6.3
Source: my bench, early October 2026

The loop I ship deals with it through what I call a self-heal: if a turn comes back empty, it re-sends that same request with reasoning switched off, and the next turn thinks normally again. Without that remedy every reasoning model in my roster would score close to zero, and its ability wouldn't be the cause. With it, the self-heal counts were 28 for the GSQ-RCO 27B, 35 each for the 35B MoE and the IQ4_XS 27B, 49 for Ornith-1.5-9B and 16 for NeoHorse.

An empty turn means the model answered inside a channel your loop doesn't read, until the budget ran out.

What to check:

  • Count turns with finish_reason=length and empty content. If they are more than a few percent, the token cap is too tight for that model with reasoning on.
  • Check how the loop recovers. A loop that gives up after the first empty turn will fail episodes that a second request would have solved.
  • Check what the recovery changes. An earlier version of my harness healed once per episode and then left reasoning off for every remaining turn. One empty reply was enough to switch the model's regime mid-episode, a far heavier intervention than re-sending one request. I found it, made the heal work per turn, and re-ran everything taken with the old loop.

A self-heal costs time. The worst case I recorded was a Strata expert-offload run on a log-summary task: 42 self-heals in 70 turns, each turn spending around three minutes reasoning before the cap, plus about 12 seconds for the re-issued call. The run reached the turn limit after 8,478 seconds without solving the task. The model kept reasoning at about 35 tokens per second into a budget too small to ever let it act. The full story of that run is in the Strata hands-on piece.

2. Check for tool calls cut in half

The second stall is nastier because it looks like a server crash. The model is writing a tool call, say a file write with a long content argument, and reaches the per-turn cap in the middle of a JSON string. The server stops generation with finish_reason=length. The reply contains a tool call whose arguments are a truncated string, not valid JSON.

My loop did what any naive loop does: it appends the assistant message to the history as it arrived, and sends the next request. llama-server then tries to parse the conversation, finds a tool call with broken arguments, and refuses the request with an HTTP 500.

In the definitive campaign this happened three times, once each on Ornith-1.5-35B-A3B, Qwen3.8-27B IQ4_XS and NeoHorse-1-9B, all three with the same shape. The previous turn closed at 6,000 generated tokens on the dot, the tool call carried arguments cut mid-string, the loop echoed it back, and the server refused to read it. One of the three happened after the tree was already correct, so that episode was still solved. The other two were scored as failures by the oracle.

I did not change the loop for this campaign, on purpose: changing the loop mid-campaign would have broken comparability with everything already measured. What changed is the scorer: it now recognises the shape and labels the episode budget_cut, outside the model's failures. The oracle's verdict stays fail, and every table reports those episodes on their own line. My rule: before you pin a failure on a model, show it could have succeeded within the budget.

What to check:

  • For every HTTP 500, look at the previous turn. If it ended with finish_reason=length and contains a tool call, the 500 is yours.
  • Validate tool-call arguments before appending them to history. A call whose arguments do not parse should not go back to the server as if it were complete.
  • Decide what the loop does with a cut call. Dropping it and asking the model to retry with shorter writes is one option; raising the cap is another. Both change what you measure, so pick one before a campaign, not during it.

3. Check the ceilings against the model's speed

The third stall is the one I misread longest. Every agent loop has a turn limit and a wall-clock limit, otherwise a confused model can run forever. But a ceiling written for one model tests something else on another. With reasoning on, a 27B dense model decodes much slower than a 3B-active MoE and spends more wall time per turn. The same 600-second ceiling is generous for one and tight for the other.

It showed up on a calibration task: a timesheet calculation spanning a daylight-saving change. The prediction I wrote before the panel was zero to two solved runs out of nine per variant. The numbers matched the prediction, two and zero out of nine, but for the wrong reason.

How the episode endedEpisodesWhat it means
Turn ceiling at 28 turns7stopped before finishing
Wall-clock ceiling at 600 s5stopped before finishing
Tool call cut by the token cap1budget_cut, not the model
Delivered a fix the oracle rejected3a real wrong answer

Twelve of the sixteen failures were ceilings, not answers. Only three episodes delivered something the hidden oracle could judge, and all three were wrong. With ceilings like these, the panel measured which model finishes in time, not which model understands daylight saving. So I ran it again with the ceilings raised. In the second round the twelve failures split into six deliveries (five with the visible tests green and the oracle against, one with the tests red), five ceilings and one budget_cut. Four of those five ceiling episodes had the visible tests already green and the code still wrong: raising the ceiling turned them from "ran out of time" into "would have shipped a wrong fix".

In the main campaign the ceilings mattered less, but they still bit. Five episodes stopped on the time ceiling, three on Ornith-1.5-9B and two on the IQ4_XS 27B, and three more on the turn ceiling, all on Ornith-1.5-9B. Two episodes that hit the time ceiling were still solved, one at 3,010 seconds and one at 611.

What to check:

  • For every failure on a ceiling, look at the last state of the visible tests. Green tests at the ceiling and red tests at the ceiling mean two different things.
  • Set ceilings per task and declare a usable threshold separately from the cap. I use a usable threshold (solved within the time a person would wait) and a hard cap (where the run is cut). A run solved after the usable threshold is solved, but not usable.
  • Never compare models measured under different ceilings. A run allowed 150 minutes and one allowed 50 are two different measurements, and my harness resets its accumulated data whenever a ceiling moves.

4. Check the context before it becomes a problem

The fourth stall did not happen in the campaign, and I include it because it is the one people expect. Agent histories grow with every tool output. A cat of a large file, a test run with a long traceback, a directory listing: they all stay in the conversation. At some point the prompt reaches the context limit and the server refuses the request or truncates it.

On my bench, with a context of 65,536 tokens, no episode hit the context ceiling. The largest prompt reached was 43,650 tokens, on Ornith-1.5-9B, the model that also used the most turns.

ModelLargest prompt in any episodeShare of the 65,536-token context
Ornith-1.5-9B43,65067%
Qwen3.8-27B IQ4_XS30,52547%
NeoHorse-1-9B26,72341%
Ornith-1.5-35B-A3B23,88636%
Qwen3.8-27B GSQ-RCO22,82035%

Context use tracks turns, not difficulty. The model that wanders fills more of the window, and the one that goes straight to the fix fills less. Halve the turns and the odds of hitting the context wall on the same task drop sharply. So if a model keeps getting close to the context limit, the path is what's too long, and a bigger context only postpones the stall.

What to check:

  • Log the prompt size at every turn, not only the final one. The peak is often in the middle of an episode.
  • Truncate tool outputs at the tool level. There's no reason for a test run that prints ten thousand lines to enter the history in full.
  • If you raise the context, verify the model reads it: loading a context and using it are two separate things, as my Italian article on how much context really fits in 16GB shows with numbers.

Tip

When an agent stalls, read the last two turns before reading anything else. In my logs the cause nearly always showed up there: the length stop, the cut tool call, the ceiling hit with the tests already green.

5. Separate stalls from wrong answers in your numbers

The last item concerns reporting, and debugging comes into it only indirectly. If stalls caused by the loop are counted as model failures, every comparison between models is contaminated by the loop. A model that reasons longer will hit the token cap more often, will self-heal more often, will produce more cut tool calls, and will look worse in a pass-rate table for reasons that have nothing to do with the code it writes.

My harness now labels every failed episode with its cause: ceiling, budget_cut, API error, or delivered and wrong. The tables in the production pair comparison report budget_cut episodes next to the solved count, never inside it. Across all models in the campaign, the duel suite had 25 failures, 19 of them silent (the visible tests passed, the hidden oracle disagreed), plus two budget_cut episodes stopped by our cap and not counted. With that split, a failure count means something.

Self-heal count per model in the definitive campaign
Hardware
RTX 5060 Ti 16GB, 180 W, PCIe Gen3 x8; Ryzen 5 4500; 32GB DDR4-3600
OS
Debian 13, NVIDIA driver 615.71.09, CUDA 13.4
Software
llama.cpp 391fac1, harness 0.4.0, --fit off, 65,536-token context, one slot, q4_0 KV cache, reasoning on, 6,000-token cap per turn, temperature 0.4, min-p 0.05, seed per task and repetition

Method: Agent loop on five tasks, three repetitions each. A self-heal is an empty turn re-issued with reasoning off.

Results (self-heals, lower is better)

Self-heal count per model in the definitive campaignvalues in self-heals
Self-heal count per model in the definitive campaign
ModelSelf-heals (self-heals)
NeoHorse-1-9B16
Qwen3.8-27B GSQ-RCO28
Ornith-1.5-35B-A3B35
Qwen3.8-27B IQ4_XS35
Ornith-1.5-9B49
Source: author's measurements, early October 2026

The self-heal count is a real property of the model in that loop, and I report it as such: how often a model has to be rescued from its reasoning says something about how it behaves in an agent. It still isn't a pass rate, and two models with different self-heal counts can still solve the same tasks.

The checklist in one place

When a local agent stalls, this is the order I go through:

  1. Empty turns. Count replies with finish_reason=length, empty content and no tool calls. More than a few percent means the cap is too tight for reasoning on.
  2. Recovery. The loop should re-send the empty request instead of giving up, and leave the model's regime alone for the rest of the episode.
  3. Cut tool calls. For every HTTP 500, look at the previous turn: did it end at the cap with a tool call? Validate arguments before they go back into history.
  4. Ceilings. For every run that ended on a turn or time ceiling, check the visible tests at the last turn. Set usable thresholds and hard caps per task.
  5. Context. Log the prompt size per turn and watch the peak. Truncate noisy tool outputs at the source.
  6. Reporting. Label every failure by cause. Never count loop failures as model failures.

Most of these checks take minutes, and all of them use data any agent loop can log: finish_reason, the content length, the tool calls, the prompt token count. The server README in the llama.cpp repository describes the fields the server returns, and the OpenAI chat completions reference defines the finish_reason values that most local servers mirror.

What changes in practice

After this I run local agents differently in two ways.

First, the token cap per turn: with reasoning on, it's a bigger decision than it looks. At 6,000 tokens, between 6% and 15% of turns ended empty on my roster. Raise the cap and you get fewer empty turns and cut calls, but a confused model also gets longer to reason before acting, and on a 16GB card a long reasoning turn on a 27B is minutes, not seconds. No single value suits every model; the right one is the one you measured. For the latency cost of that choice, see the article on the reasoning tax on a local LLM.

Second, I don't read a pass rate anymore without the endings next to it. A model that fails on ceilings with green tests behaves very differently from one that ships wrong code, and that second kind should worry you. The piece on green tests and wrong code covers that difference and how a hidden oracle catches the wrong fix. For more measurement traps in llama.cpp, from the prompt cache to parallel slots, see what llama.cpp benchmarks get wrong.

Where this leaves the decision

A local coding agent that stalls is usually telling you something about the loop. The four causes I measured, empty reasoning turns, cut tool calls, ceilings sized for another model, and growing context, account for every stall in my campaign that was not a wrong answer. You don't fix any of them with a better model. You fix them with a loop that logs what happened and a report that counts loop failures apart from model failures.

If you are building an agent on local models and the stalls are eating your evaluation, or you want a second pair of eyes on how your loop recovers, you can describe the setup in my free quote form. It takes two minutes, and I will tell you straight away whether it fits what I do.

Ultima modifica: