Bug Description
The DeepSeek V3 tool call parser regex is missing the re.DOTALL flag, so .* doesn't match newlines. Since tool call arguments are almost always multi-line JSON, the parser silently fails to extract them and returns the raw text instead of parsed tool calls.
Steps to Reproduce
- Set
TOOL_CALL_PARSER=deepseek_v3 in config
- Use a DeepSeek V3 model that produces tool calls
- The model outputs a tool call with multi-line JSON arguments (the normal case)
- The parser returns
(text, None) instead of extracted tool calls
- The agent treats the tool call as plain text
Expected Behavior
The parser should extract tool calls regardless of whether the JSON arguments are single-line or multi-line.
Actual Behavior
The parser only works when JSON arguments fit on a single line (e.g. {"query": "hello"}). Any multi-line JSON causes the regex to fail silently, and tool calls are dropped.
Affected Component
Agent Core (conversation loop, context compression, memory)
Messaging Platform (if gateway-related)
N/A (CLI only)
Operating System
Ubuntu 24.04
Python Version
3.11.9
Hermes Version
1.0.0
Relevant Logs / Traceback
Root Cause Analysis (optional)
In environments/tool_call_parsers/deepseek_v3_parser.py, the regex at line 40-42:
PATTERN = re.compile(
r"<|tool▁call▁begin|>(?P<type>.*)<|tool▁sep|>(?P<function_name>.*)\n```json\n(?P<function_arguments>.*)\n```<|tool▁call▁end|>"
)
Without re.DOTALL, .* does not match \n. The function_arguments group needs to match multi-line JSON between the json code fence markers, but stops at the first newline.
Every other parser in the codebase that needs to match across lines uses re.DOTALL:
hermes_parser.py - uses re.DOTALL
mistral_parser.py - uses re.DOTALL
glm45_parser.py - uses re.DOTALL
glm47_parser.py - uses re.DOTALL
qwen3_coder_parser.py - uses re.DOTALL
kimi_k2_parser.py - uses re.DOTALL
longcat_parser.py - uses re.DOTALL
Proposed Fix (optional)
Add re.DOTALL flag to the regex compilation.
Are you willing to submit a PR for this?
Bug Description
The DeepSeek V3 tool call parser regex is missing the
re.DOTALLflag, so.*doesn't match newlines. Since tool call arguments are almost always multi-line JSON, the parser silently fails to extract them and returns the raw text instead of parsed tool calls.Steps to Reproduce
TOOL_CALL_PARSER=deepseek_v3in config(text, None)instead of extracted tool callsExpected Behavior
The parser should extract tool calls regardless of whether the JSON arguments are single-line or multi-line.
Actual Behavior
The parser only works when JSON arguments fit on a single line (e.g.
{"query": "hello"}). Any multi-line JSON causes the regex to fail silently, and tool calls are dropped.Affected Component
Agent Core (conversation loop, context compression, memory)
Messaging Platform (if gateway-related)
N/A (CLI only)
Operating System
Ubuntu 24.04
Python Version
3.11.9
Hermes Version
1.0.0
Relevant Logs / Traceback
Root Cause Analysis (optional)
In
environments/tool_call_parsers/deepseek_v3_parser.py, the regex at line 40-42:Without
re.DOTALL,.*does not match\n. Thefunction_argumentsgroup needs to match multi-line JSON between the json code fence markers, but stops at the first newline.Every other parser in the codebase that needs to match across lines uses
re.DOTALL:hermes_parser.py- usesre.DOTALLmistral_parser.py- usesre.DOTALLglm45_parser.py- usesre.DOTALLglm47_parser.py- usesre.DOTALLqwen3_coder_parser.py- usesre.DOTALLkimi_k2_parser.py- usesre.DOTALLlongcat_parser.py- usesre.DOTALLProposed Fix (optional)
Add
re.DOTALLflag to the regex compilation.Are you willing to submit a PR for this?