Fix: Add broken tool call repair function to parser
- 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.
Showing
Please
register
or
sign in
to comment