1. 19 Mar, 2026 20 commits
  2. 18 Mar, 2026 20 commits
    • Your Name's avatar
      Fix: Handle both dict and Pydantic Tool models in templates.py · 1c79d9ab
      Your Name authored
      - Fixed AttributeError where Tool.get() was called on Pydantic model
      - Added isinstance() checks to handle both dict and Pydantic Tool formats
      - This fixes the error when using --force-reasoning with tools
      1c79d9ab
    • Your Name's avatar
      Fix: Update VulkanBackend method signatures to match base class · 673ac596
      Your Name authored
      - Added repeat_penalty, presence_penalty, frequency_penalty params to generate() and generate_stream()
      - Changed from **kwargs to explicit parameters to match base class abstract methods
      
      This fixes the TypeError when calling VulkanBackend.generate_stream() with extra params.
      673ac596
    • Your Name's avatar
      Fix: Add repeat_penalty, presence_penalty, frequency_penalty params to NvidiaBackend · 4249e178
      Your Name authored
      - Added missing parameters to generate() and generate_stream() methods
      - Updated _generate_normal() and _generate_stream_normal() to use these params
      - Also updated base.py abstract method signatures to match
      
      This fixes the TypeError when using repeat_penalty with NVIDIA backend.
      4249e178
    • Your Name's avatar
      Fix: Expand tool call repair for all hallucinated formats from debug.log · 441ea0fb
      Your Name authored
      New patterns added to repair_broken_tool_calls():
      
      1. Pattern 4: <tool><function>NAME</function><parameters>XML</parameters></tool>
         - Converts XML parameters to JSON format
         - Fills missing required params (e.g., path for list_files)
      
      2. Pattern 0a: <tool><NAME><params></NAME></tool> (with closing tool name tag)
         - Handles format with closing tag for tool name
      
      3. Expanded guard to detect known tool names used as wrapper tags
         - Now detects <fetch_instructions>, <list_files>, etc.
      
      4. Fixed closure bug in Pattern -2 (wrong wrapper tags)
         - Used default argument to capture loop variable correctly
      
      5. Post-processing: Fill missing required parameters
         - list_files gets path='.' if missing
         - search_files gets path='.' if missing
      
      All 6 test cases pass:
      - <tool><function>list_files</function><parameters>...</parameters></tool> -> OK
      - <fetch_instructions><task>read_file</task>...</fetch_instructions> -> OK
      - <tool_call><list_files></list_files></tool_call> -> OK
      - <tool><list_files><path>.</path></list_files></tool> -> OK
      - Valid JSON passthrough -> OK
      - Missing required params auto-filled -> OK
      441ea0fb
    • Your Name's avatar
      Fix: Expand broken tool call repair patterns · f6c2bf8e
      Your Name authored
      Added 3 new repair patterns to handle additional hallucinated formats:
      
      1. Pattern -1: Fix <tool_call> wrapper format
         - Converts <tool_call><list_files></list_files> to proper <tool> wrapper
         - Handles nested <tool_call><tool>...</tool></tool_call> format
      
      2. Pattern -2: Handle wrong wrapper tags
         - Fixes when model uses tool name as wrapper: <fetch_instructions>...</fetch_instructions>
         - Converts to proper JSON format: {"name": "tool_name", "arguments": {...}}
         - Supports all known tools (read_file, list_files, etc.)
      
      3. Pattern -3: Handle incomplete tool calls with missing parameters
         - Detects <tool><list_files></list_files> (no parameters)
         - Provides sensible defaults: list_files gets path='.' and recursive=False
         - Prevents extraction failures due to missing required parameters
      
      These patterns fix the hallucination issues observed in debug.log where the model
      produces broken XML formats despite --ggg (grammar-guided generation) being enabled.
      f6c2bf8e
    • Your Name's avatar
      Fix: Add broken tool call repair function to parser · 3b7407c2
      Your Name authored
      - Added repair_broken_tool_calls() function that handles common hallucinated formats:
        - <tool><tool_name><param>value</param></tool> (missing closing tag)
        - <tool><tool_name><param>value</param></tool_name></tool>
        - Simple format: <tool><list_files><path>.</path><recursive>true</recursive></tool>
      
      - Integrated repair into:
        - QwenParser.parse() - primary parser for Qwen models
        - ToolCallParser.extract_tool_calls() - fallback parser
        - ModelParserAdapter.extract_tool_calls() - adapter wrapper
      
      The repair converts broken XML format to valid JSON:
      <tool><list_files><path>.</path><recursive>true</recursive></tool>
      becomes:
      <tool>{"name": "list_files", "arguments": {"path": ".", "recursive": true}}</tool>
      
      This fixes tool call extraction when the model hallucinates broken XML tags.
      3b7407c2
    • Your Name's avatar
      feat: Pipeline fixes, regex optimization, GBNF grammar support, and prompt distillation · 5341ee6a
      Your Name authored
      - Fixed streaming mode pipeline issues:
        - Fixed n-gram counting to handle partial matches correctly
        - Added per-chunk filtering to prevent duplicate n-grams across chunks
      
      - Optimized regex patterns (~35 patterns pre-compiled):
        - Pre-compiled all regex patterns for better performance
        - Added false positive protection with length-based filtering
        - Optimized tool call parsing in parser.py
      
      - Added grammar-guided generation (--ggg / --grammar-guided-gen):
        - New GBNF grammar file (tool_call_grammar.gbnf) for tool call parsing
        - Grammar loading utilities in models/grammar.py
        - Vulkan backend: Added GBNF grammar support via llama_generate_grammar
        - CUDA backend: Added outlines support for structured output
      
      - Added prompt distillation (--tools-closer-prompt):
        - New CLI option --tools-closer-prompt for prompt distillation
        - Enables generating distilled tool descriptions for better accuracy
      5341ee6a
    • Your Name's avatar
      Fix tool extraction and repetition detection · d9cba7ec
      Your Name authored
      - Add repetition filtering for model output (n-gram detection)
      - Improve reasoning extraction to exclude tool call content
      - Add JSON validation for extracted tool calls
      - Ensure fixes work in both streaming and non-streaming modes
      d9cba7ec
    • Your Name's avatar
      Fix: Parse JSON object inside <tool> tags · 72917a8a
      Your Name authored
      - Add pattern for <tool>{JSON}</tool> format
      - Handles: <tool>{"name": "web_search", "arguments": {...}}</tool>
      72917a8a
    • Your Name's avatar
      Fix: Parse nested XML arguments inside <arguments> tags · 625ea1d8
      Your Name authored
      - Add patterns to handle <arguments><command>...</command></arguments> format
      - Add patterns to handle <tool_call><tool><name>...<arguments>...nested XML...</arguments></tool></tool_call>
      - Fix tool call argument extraction for nested XML formats
      625ea1d8
    • Your Name's avatar
      Add ToolCallParser as fallback for all model parsers and enhance multi-line tool call parsing · 63bed9c0
      Your Name authored
      - Added _parse_multiline_tool_calls() method to handle multi-line tool_call format
      - Added ToolCallParser fallback to all specific model parsers:
        - QwenParser, DeepSeekParser, LlamaParser, MistralParser
        - ClaudeParser, CommandRParser, GemmaParser, GrokParser
        - PhiParser, ApexBig50Parser
      - Updated extract_tool_calls() to use both XML and multi-line parsing
      - Tested and verified tool call extraction works for user's example format
      63bed9c0
    • Your Name's avatar
      Fix tool extraction in streaming: use reasoning text as fallback when second pass is empty · 43873a46
      Your Name authored
      - When second pass result is empty, try extracting tool calls from reasoning text
      - Add debug message when falling back to reasoning text
      - This helps when the model generates reasoning but no content in second pass
      43873a46
    • Your Name's avatar
      Remove debug log file · 30f34e23
      Your Name authored
      30f34e23
    • Your Name's avatar
      Add model settings to debug request logging · 4fa65576
      Your Name authored
      - Display temperature, top_p, max_tokens, stop, presence_penalty, frequency_penalty, repeat_penalty
      - Display tool_choice, response_format, user, enable_thinking
      - Improved messages display with tool_calls and reasoning indicators
      - Display tools list with function names and descriptions
      4fa65576
    • Your Name's avatar
      Fix streaming debug dumps and add ToolCallParser support for streaming path · 59a17f81
      Your Name authored
      - Add debug dumps to raw_stream_generate() for LLM response and reasoning text
      - Add ToolCallParser (ModelParserAdapter) support in streaming path
      - Extract tool calls from second pass result and yield as tool_calls chunk
      - Add debug output for extracted tool calls in streaming mode
      59a17f81
    • Your Name's avatar
    • Your Name's avatar
    • Your Name's avatar
    • Your Name's avatar
    • Your Name's avatar