Skip to content

Fix: minicpm5-2b native tool calls never parse - #18499

Open
SIDDARTHAREDDY8 wants to merge 1 commit into
ollama:mainfrom
SIDDARTHAREDDY8:oss-bhai-2026-09-16c
Open

SIDDARTHAREDDY8 wants to merge 1 commit into
ollama:mainfrom
SIDDARTHAREDDY8:oss-bhai-2026-09-16c

Conversation

@SIDDARTHAREDDY8

Copy link
Copy Markdown

Fixes #18483.

Fix #18483: MiniCPM5 native tool calls never parse. Root cause: MiniCPM5 emits tool calls as XML using special vocabulary tokens (//etc.), but the runner stripped those tokens during detokenization, leaving mangled fragments like name="get_weather"> that no parser could recognize. Change: (1) new MiniCPM5Parser in model/parsers that preserves all 8 XML tool-call special tokens and parses ... blocks (streaming-safe, handles thinking, wrappers, CDATA params, unknown-tool fallback to content); registered as "minicpm5" in ParserForName; (2) template-based auto-detection (MiniCPM5 identifies as generic llama, so identifiers cannot detect it) via create.IsMiniCPM5ChatTemplate, wired into safetensors inference (create/metadata.go) and GGUF create path (server/create.go). Once parsed, tool_calls flow through the existing response paths and OpenAI finish_reason is rewritten stop->tool_calls automatically.

Tests pass: go test ./model/parsers/ (all pass incl. 17 new MiniCPM5 cases: native tool call incl. the issue exact get_weather/Paris scenario, streaming split-tag cases, thinking, CDATA, wrapper, multiple calls, unknown-tool fallback, preserved-tokens, registration); go test ./create/ (all pass incl. new minicpm5 safetensors-family and capabilities cases); go vet clean on both packages; gofmt clean. server/create.go edit verified in context (syntax-ok; package-level compile blocked only by sparse-checkout sibling files, no type errors in the edited file).

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.

minicpm5-2b native tool calls never parse

1 participant