-
Stefy Lanza (nextime / spora ) authored
gemma-4 GGUF finetunes emit a corrupted tool-call scheme that broke both extraction and display, e.g.: <|tool_call>call:bash{command:<|"|>wc -l README.md<|"|>}<tool_call|><|tool_response>… Three distinct corruptions, all now handled by normalize_gemma_tool_tokens(): - <|"|> is the model's stand-in for a " quote — it leaked verbatim into string args, so a bash command became <|"|>wc -l<|"|> and failed with "syntax error near unexpected token |". Restored to a real ". - malformed open/close markers <|tool_call> / <tool_call|> (vs the canonical <|tool_call|>) — stripped, so the native call:NAME{…} body parses and the markers don't leak as text. The canonical <|tool_call|> / <|tool_call_end|> are deliberately left intact so Phi-style parsing is unaffected. - a hallucinated <|tool_response>…/<turn|> tail (the model fakes the tool result) — stripped, and strip_tool_calls_from_content now also drops response:NAME{…} spans so the fake result never reaches the user or gets executed. Wired into ModelParserAdapter + ToolCallParser (extract & strip) and cleanup_control_tokens, covering the streaming, non-streaming and fallback paths. Co-Authored-By:Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011DDv7BchtZQWsnPG6Jm49m
5135f8f8