Bug: long running agent tasks in Ollama leads to unexpected stop tokens before tool calls
Maintainer antworten meist innerhalb von 2 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 74/100
Rechercherichtung
Start in src/eca/llm_providers/ollama.clj and read normalize-messages, comparing its message handling with the Anthropic adapter’s merge-adjacent-assistants. Check how request JSON keys are encoded and how assistant history items become Ollama chat messages. Done means prior tool calls are sent with the expected key and consecutive assistant content and tool calls are grouped as described; the issue names no test file, so locate the relevant provider tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
Describe the bug
When using the Ollama API and long running agent tasks, the models (tested on qwen 3.5/3.8) emit unexpected stop tokens where a tool call is expected.
To Reproduce
Steps to reproduce the behavior:
- Use a model hosted by Ollama with the Ollama Api
- Start a long running task
- At some point the model outputs:
Now I edit file X <stop_token>
Expected behavior
The model emits a tool call request instead of the stop token.
Cause and fix
The reason for the behavior is twofold. Both problems are in normalize-messages in src/eca/llm_providers/ollama.clj.
-
Previous tool calls are silently dropped. The assistant tool-call messages are built with the key
:tool-calls, and the body is encoded with a plain(json/generate-string body)(no key-fn), so the wire key is"tool-calls". Ollama's/api/chatexpectstool_calls(API docs) and silently ignores unknown fields, so the request succeeds but the model never sees its earlier tool calls. (The response side already reads:tool_callscorrectly.) -
One model response is sent as several assistant turns. Each history item becomes its own message: the reasoning (as plain
content), the visible text, and the tool call. Ollama renders every assistant message as its own finished turn. The model's history therefore contains many turns of the form "I'll do X now", followed by an end-of-turn marker. That never happened during generation, where the call followed in the same turn. The model imitates the pattern and ends its turn right after announcing the action, so the stop token becomes likely. Each failure also adds another such example, which is why it gets worse in long sessions.
Fix
- Use
:tool_callsinstead of:tool-calls. - Merge consecutive assistant messages into one (reasoning first, then text, joined by a blank line, with all tool calls concatenated). A
toolmessage between two responses keeps them separate. The Anthropic adapter already does this withmerge-adjacent-assistants.
Workaround until released
Pointing the provider at Ollama with "api": "anthropic" avoids the problem, because that adapter already merges messages and sends tool_use blocks (Ollama converts them to tool_calls).
- Vorherrschende Sprache
- Clojure
- Sterne
- 1k
- Forks
- 82
- Ø Merge
- 2 T. 1 Std.
- Gemergte PRs (30 T.)
- 23
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus editor-code-assistant/eca
-
Models doesn't work when fetchModels: false is usedEvtl. vergeben @zikajk hat das vor 9 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
editor-code-assistant/eca#661 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 52/100
editor-code-assistant/eca#685 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
editor-code-assistant/eca#684 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
editor-code-assistant/eca#683 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bug
Schwierigkeit 4/5 1-2 Tage Anfängerfreundlichkeit 54/100
editor-code-assistant/eca#674 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in editor-code-assistant/eca
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
module:rest-api
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
WG adoption
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 4 Tagen