• Stefy Lanza (nextime / spora )'s avatar
    parser: repair gemma-4's corrupted tool-call tokens (<|"|> quotes, bad markers) · 5135f8f8
    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: 's avatarClaude Opus 4.8 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_011DDv7BchtZQWsnPG6Jm49m
    5135f8f8
Name
Last commit
Last update
..
cache Loading commit data...
__init__.py Loading commit data...
acceleration.py Loading commit data...
capabilities.py Loading commit data...
grammar.py Loading commit data...
hf_loading.py Loading commit data...
manager.py Loading commit data...
parser.py Loading commit data...
pipeline_cache.py Loading commit data...
quant.py Loading commit data...
ram_monitor.py Loading commit data...
templates.py Loading commit data...
thermal.py Loading commit data...
tmp_janitor.py Loading commit data...
tool_call_grammar.gbnf Loading commit data...
turboquant.py Loading commit data...
utils.py Loading commit data...