Gave it a simple coding task, it began looping and hallucinating hard

#5
by Indexnusrefather - opened

Hello, first of all, I would like to thank you, I really like what you're doing. However, this model has severe coherence issues.
Screenshot 2026-06-19 070828
I gave it a simple prompt to test it out(told it to create a simple HTML5 game) and it broke down miserably...

Hey, first off β€” thank you, genuinely. Glad you're enjoying the work, and thanks for taking the time to write up such
a clear report with the screenshot. That made this easy to pin down.

Good news: this isn't a problem with the weights β€” it's a harness config issue, and it's fully fixable on your side.
Two things are stacking here:

  1. The runaway 0000… is the sampler. That's classic degenerate repetition. KoboldCpp ships with rep_pen = 1.0 (no
    repetition penalty) by default, so once the model emits a long numeric path, nothing stops it from looping zeros
    forever. I reproduced this exact 0000… collapse on Q4_K_M under default sampling, and it disappears with proper
    settings. Please set: temp 1.0, top_p 0.95, top_k 64, rep_pen 1.1 β€” and if your build has it, DRY multiplier ~0.8.
    Q4_K_M is clean here with those.
  2. The leaked <|channel> and <|tool_call>call:...{} tokens mean your front-end isn't parsing Gemma 4's native tool
    format. Those aren't gibberish β€” they're Gemma 4's native control tokens (<|channel>thought … <channel|> for the
    reasoning channel, and <|tool_call>call:name{args}<tool_call|> for tool calls). KoboldCpp needs a recent build with
    the --jinjatools option to parse them back into real tool calls; without it they leak as raw text. The most reliable
    path for agentic/tool use is llama.cpp's llama-server --jinja, which has the proper parser for Gemma 4's tool
    protocol. So: update KoboldCpp to the latest and add --jinjatools, or switch to llama-server --jinja.

Fix the sampler and the tool parsing and the "incoherence" should be gone. One honest caveat: in very long autonomous
multi-step loops a 12B will still occasionally invent a tool that isn't in your set (here EssentiaPy...compile) β€”
keeping the tool list small and adding "complete all steps before yielding" to the system prompt helps.

I've pinned this thread so everyone running into the same thing can find the fix.

And please β€” if anything else comes up, don't hesitate to post here in the community. I check it and will reply as
fast as I can.

yuxinlu1 pinned discussion

I appreciate the attention to this matter! Updating on the issue: The sampling did fix the issue with looping. I did enable the jinjatools in kobold(using most recent version of kobold), however, results were most unexpected, I'll leave a proper screenshot:
Screenshot 2026-06-19 093425

It stops abruptly, most likely kobold issue, I'll later test this out with other backends...

+1 here.

I would like to call out the positives first. The model was able to do a bunch of appropriate tool calls at the very start.

However, it proceeded to hallucinate to the extent that the model itself said that it is hallucinating.

Screenshot From 2026-06-22 15-07-43
Screenshot From 2026-06-22 15-17-31

+1 here.

I would like to call out the positives first. The model was able to do a bunch of appropriate tool calls at the very start.

However, it proceeded to hallucinate to the extent that the model itself said that it is hallucinating.

I mean just off the bat im not surprised. Your prompt was:

Can you explain this codebase to me please?

Thought: 3.9s

Large request - "explain this codebase" for a 5820-Line TypeScript React app with no index.ts/md landing page and the user asking in Korean. First step: orient myself on high level before diving into details. List files, grep top dirs to locate entry point (App.tsx?),
check package. json dependencies (react, ui libs), and use codemap for a structured overview of the codebase architecture I can share with them later. Keep response brief; I'll build understanding through tools first.

Question : Is it hallucinating about a 5820-Line TypeScript file?

  • Do you have a main.ts that large because if thats the case id also start hallucinating if i was tasked to read it and explain it. If it hallucianted the file then sure valid. But if not i suggest trying to learn more on the limitations. And Also perhaps first start to learn basicis of maintainable readable code . If a humans not gonna read it, expecting a brand new experimental local model to do this is naive.

  • I tried the q8 model now. And it works well considering. Thats for the 12b which i honeslty wasnt expecting much fom it was more so just a smoke test , currently waiting on the 3.6 27b to download and will play with it more until then and see if its able to onboard to more complex workspace .If i come off as condescending im sorry its just at first glace i just saw 5000 lines of code and yeah thats the bottleneck if its real. Local Ai is finnicky though you wanna set reasonable expectations or smaller models also.

Thanks for letting us know

@KoushikSahu @Jexposition Thanks for the detailed trace β€” and for calling out the good part first. I'll be straight: this one isn't the sampler or the harness, it's the genuine weak spot of a 12B in long autonomous loops, and your log shows it exactly.

What's happening: it makes the right opening moves (glob, list, lsp), but the first few "not found" results don't make it re-ground β€” instead it guesses another absolute path, then another, and its own failed guesses pile up in context until it treats them as real "session data" and spirals. It even narrates that it's hallucinating, which means it knows but can't break the loop on its own at this size. That's precisely the execution-robustness axis β€” over-guessing, repeating failed calls, inventing paths β€” that v3 (aiming for before next Wednesday) is built to target. Not waving it away; it's the real limitation and it's the thing I'm working on.

What helps a lot right now:

  • Cut the tool surface. You've got ~8 MCP servers + LSP wired in; every extra tool is another way to emit a bad-arg call. Fewer tools β†’ far fewer of those "schema error / failed call" loops.
  • Drop temperature to ~0.4 for agentic/grounding work (keep rep_pen ~1.1). The temp 1.0 I gave earlier was for the creative HTML task; high temp makes it invent paths and IDs.
  • Don't cold-start with "explain the whole codebase." Hand it an entry file, or let it ls -R first and feed the tree. A 5820-line single file with no landing page (as @Jexposition noted) is about the hardest cold start there is.
  • Fresh session per task, so stale paths from a prior run don't poison the new one β€” that's the "old session data" it keeps blaming.

@Jexposition β€” agreed on all of it, and thanks for the fair read on the q8 smoke test. Honest framing for a 12B local: it's a focused worker, not yet a drop-in autonomous agent for a cold large repo. That gap is squarely what v3 is for.

Sign up or log in to comment