Skip to content

model/parsers: Close think block if tool block starts in Qwen3.5 - #15022

Merged
ParthSareen merged 1 commit into
ollama:mainfrom
amatas:parse_tool_open_thinking
Mar 27, 2026
Merged

ParthSareen merged 1 commit into
ollama:mainfrom
amatas:parse_tool_open_thinking

Conversation

@amatas

@amatas amatas commented Mar 23, 2026 •

Copy link
Copy Markdown
Contributor

This change fixes #14745 when the model starts a tool_call block without closing the think block:

Thinking: I need to mock Valkey for tests. Let me check how the app initializes Valkey and update TESTING.md with this information.
<tool_call>
<function=bash>
<parameter=command>
grep "redacted" | head -20
</parameter>
<parameter=description>
Find Valkey initialization
</parameter>
</function>
</tool_call>

I saw this behavior while using Opencode + Ollama 0.18.2 + qwen3.5:9b. I have been working for a couple of days with the same setup and this patch without problems.

Issues that can be fixed with this PR as well:

external:

Regards, and thank you all for this great tool.

@EntropyYue

Copy link
Copy Markdown
Contributor

In my tests, this can solve the problem

@ParthSareen
ParthSareen merged commit 1cefa74 into ollama:main Mar 27, 2026
8 checks passed
@ParthSareen

Copy link
Copy Markdown
Member

Thanks for the PR @amatas! I think this is a good fix with the caveat that it will have a cache breakage. We use this pattern in a couple other spots so should be okay!

alexlebens pushed a commit to alexlebens/infrastructure that referenced this pull request Mar 30, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ollama/ollama](https://github.com/ollama/ollama) | minor | `0.18.3` → `0.19.0` |
| ollama/ollama | minor | `0.18.3` → `0.19.0` |

---

### Release Notes

<details>
<summary>ollama/ollama (ollama/ollama)</summary>

### [`v0.19.0`](https://github.com/ollama/ollama/releases/tag/v0.19.0)

[Compare Source](ollama/ollama@v0.18.3...v0.19.0)

#### What's Changed

- Ollama's app will now no longer incorrectly show "model is out of date"
- `ollama launch pi` now includes web search plugin that uses Ollama's web search
- Improved KV cache hit rate when using the Anthropic-compatible API
- Fixed tool call parsing issue with Qwen3.5 where tool calls would be output in thinking
- MLX runner will now create periodic snapshots during prompt processing
- Fixed KV cache snapshot memory leak in MLX runner
- Fixed issue where flash attention would be incorrectly enabled for `grok` models
- Fixed `qwen3-next:80b` not loading in Ollama

#### New Contributors

- [@&#8203;amatas](https://github.com/amatas) made their first contribution in [#&#8203;15022](ollama/ollama#15022)

**Full Changelog**: <ollama/ollama@v0.18.3...v0.19.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My45OS4xIiwidXBkYXRlZEluVmVyIjoiNDMuOTkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZG9ja2VyIl19-->

Reviewed-on: https://gitea.alexlebens.dev/alexlebens/infrastructure/pulls/5286
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
rick-github pushed a commit to rick-github/ollama that referenced this pull request Jul 13, 2026
electricwolfemarshmallowhypertext pushed a commit to electricwolfemarshmallowhypertext/ollama that referenced this pull request Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

qwen3.5:9b sometimes prints out tool call instead of executing it

3 participants