Support Qwen/Hermes inline <tool_call> format when native function calling is unavailable#30
Draft
Support Qwen/Hermes inline <tool_call> format when native function calling is unavailable#30
<tool_call> format when native function calling is unavailable#30Conversation
Closed
Agent-Logs-Url: https://github.com/HarnessLab/claw-code-agent/sessions/ce91ab31-3fed-422b-9a2c-8d6f6f8127e8 Co-authored-by: abdoelsayed2016 <27821589+abdoelsayed2016@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with creating TEST_QWEN_AGENT.md file
Support Qwen/Hermes inline Apr 22, 2026
<tool_call> format when native function calling is unavailable
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.
Qwen models served via vLLM without native OpenAI function-calling support emit tool invocations as
<tool_call>XML blocks inside the message content withfinish_reason: stop, bypassing the structuredtool_callsfield entirely. The agent treated these responses as plain text and returned without executing any tools.Changes
src/openai_compat.py— Addextract_tool_calls_from_content(content): parses<tool_call>…</tool_call>blocks out of content, returning extractedToolCallobjects and cleaned content. Handles both"arguments"and"parameters"key variants.OpenAICompatClient.complete()now falls back to this whentool_callsis absent from the response.src/agent_runtime.py— Streaming path (_get_assistant_turn) applies the same fallback after accumulation, and patches the session message with cleaned content + properly-serialized tool calls so conversation history remains consistent on subsequent turns.tests/test_agent_runtime.py— Two new tests: unit test forclient.complete()parsing the inline format, and an end-to-end test verifying the file is actually written when the model uses<tool_call>content blocks.