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