Invalid tool call parsing in thinking token for hermes format in tool_parser.py in agent_loop from experiment folder.
Hello
in HermesToolParser class.. extract_tool_calls function does eliminate content from <think>..</think> tags for searching for tool call signature..
this lead to case where tool call syntax used in thinking tokens consider as valid tool call.
example (Formatting for readability purposes)
<think>
this is just my reasoning.. let me call tool A
<tool_call>{"name": "A", "arguments": {}}</tool_call>
it will give me result which i will in my analysis
</think>
<tool_call>{"name": "A", "arguments": {}}</tool_call>
in above dummy example tool_call is used in side thinking token and out side also.. parser will consider this as two tool call..
I am wondering is it correct behaviour?
Good catch — this also affects Qwen3XMLToolParser (qwen3_coder) in the same file. The _get_function_calls() method searches for <function=...> patterns across the full decoded text without stripping <think>...</think> first, so reasoning-time tool-call speculation gets treated as a real call (same duplicate-call problem you described for Hermes).
Only GptOssToolParser currently handles this correctly — it strips its CoT analysis channel before running the tool-call regex.
This is actually not trivial to fix properly, because different model families use different thinking/reasoning formats:
- Qwen3.5 / DeepSeek-R1 →
<think>...</think>+ optionalresponsesentinel - GPT-OSS →
<|channel|>analysis<|message|>...<|end|> - Other reasoning models may use yet other conventions
A simple regex-based workaround in each tool parser would be fragile across models. The right long-term solution is probably a reasoning parser abstraction in the agent loop (similar to vLLM's BaseThinkingReasoningParser / qwen3_reasoning_parser) that separates reasoning blocks before tool parsing, so that all tool parsers automatically get clean action content regardless of the underlying model's thinking format.
Would be great to hear from the maintainers on whether this is something they'd consider adding to the agent loop pipeline.