• 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
parser.py 72.3 KB