fix(providers): extract tool calls from text-based format#213
Merged
Conversation
…red format Some models (e.g. Qwen3.5) occasionally emit tool calls as XML-like text (<tool_call><function=NAME>...) instead of using the structured tool_calls response field. Add a fallback parser in OpenAiCompatibleChatClient that detects this pattern in both streaming and non-streaming paths, extracts structured FunctionCallContent, and promotes finish_reason to ToolCalls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<tool_call><function=NAME><parameter=KEY>VALUE</parameter></function></tool_call>) instead of using the structuredtool_callsresponse fieldTextToolCallParserinNetclaw.OpenAICompatiblethat detects this pattern and extracts structuredFunctionCallContentParseChatResponse) and streaming (GetStreamingResponseAsync) paths as a post-processing fallback — only activates when no structured tool calls were receivedTest plan
ExtractsToolCalls_FromTextBasedFormat_WhenModelSkipsStructuredFormatvalidates extraction, argument parsing, text stripping, and finish_reason promotionOpenAiCompatibleChatClientTestspass