Skip to content

Support vllm style --tool-call-parser for hermes, qwen35, gemma4 - #162

Merged
SearchSavior merged 6 commits into
mainfrom
tool-parse-1
Sep 4, 2026
Merged

Support vllm style --tool-call-parser for hermes, qwen35, gemma4#162
SearchSavior merged 6 commits into
mainfrom
tool-parse-1

Conversation

@SearchSavior

@SearchSavior SearchSavior commented Sep 3, 2026

Copy link
Copy Markdown
Owner

This PR implements a proper token level parser for reasoning and tool invocation.

The core idea is, we stream raw ids into a buffer, check them for where the boundaries are, slice at those points, then tokenize, then join it all back together into openai compatible buckets. APIs in ovgenai used in this PR are source only, absent in all examples and not used in any code I have researched before. PR 162 may be a reference implementation for IncrementalParser and a few other classes, at least on the python side.

This approach is extremely durable- issues we have had in the past should be gone, and the format of per model tool parser and load time selection will be the standard going forward.

How to use

openarc add now accepts --tool-call-parser just like vllm! hermes style still scans text and should be used for models older than qwen3. Just add this arg to your qwen35/36/38 or gemma4 config entry and

SearchSavior and others added 6 commits August 22, 2026 17:10
Gemma 4 protocol tags are all special=True, so they never appear in decoded
text; boundaries are detected by token ID only (tool_call=48/49,
channel=100/101).

- gemma4.py: Gemma4ToolCallParser (incremental OpenAI argument fragments,
  ramble-detect stop, sequential parallel calls), Gemma4ChannelSplitter
  (thought-channel reasoning split), Gemma4ToolCallStreamer (StreamerBase,
  own decode, protocol-ID interception, raw_text reconstruction for
  non-streaming VLM where decode always strips specials), and a raw-text
  parse_generation for routes.
- streamers.py: ensure_tool_call_parser falls back to the model's load-time
  registered parser when a request carries none; select_streamer activates
  the gemma4 engine streamer when tools are present OR thinking is enabled.
- vlm.py: gemma4 non-streaming generates through the streamer and returns
  streamer.raw_text (VLM decode always strips special tags on this wheel).
  llm.py: raw decode via Tokenizer.decode(skip_special_tokens=False).
- registration/CLI/routes: 'gemma4' parser option end to end.
- Tests: gemma4 unit section (55 file total), integration (offline streamer
  contract + live GPU test); 163 unit / 6 integration green; 15/15
  openai-library server checks on gemma-4-E4B-it (GPU.0).
@SearchSavior
SearchSavior merged commit 311e145 into main Sep 4, 2026
1 check passed
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.

1 participant