Skip to content

fix(providers): extract tool calls from text-based format#213

Merged
Aaronontheweb merged 1 commit into
devfrom
fix/text-based-tool-call-fallback
Mar 13, 2026
Merged

fix(providers): extract tool calls from text-based format#213
Aaronontheweb merged 1 commit into
devfrom
fix/text-based-tool-call-fallback

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

Summary

  • Some models (Qwen3.5 observed) occasionally emit tool calls as XML-like text (<tool_call><function=NAME><parameter=KEY>VALUE</parameter></function></tool_call>) instead of using the structured tool_calls response field
  • Adds TextToolCallParser in Netclaw.OpenAICompatible that detects this pattern and extracts structured FunctionCallContent
  • Wired into both non-streaming (ParseChatResponse) and streaming (GetStreamingResponseAsync) paths as a post-processing fallback — only activates when no structured tool calls were received
  • Follows the same pattern as the existing tool call parsing: lives in the chat client, transparent to the session actor

Test plan

  • New test ExtractsToolCalls_FromTextBasedFormat_WhenModelSkipsStructuredFormat validates extraction, argument parsing, text stripping, and finish_reason promotion
  • All 7 OpenAiCompatibleChatClientTests pass
  • Deployed to local daemon and verified healthy against live lemonade/Qwen3.5

…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.
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) March 13, 2026 16:36
@Aaronontheweb Aaronontheweb merged commit bc52187 into dev Mar 13, 2026
2 of 3 checks passed
@Aaronontheweb Aaronontheweb deleted the fix/text-based-tool-call-fallback branch March 13, 2026 16:40
@Aaronontheweb Aaronontheweb mentioned this pull request Mar 13, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant