Skip to content

fix: add missing re.DOTALL flag to DeepSeek V3 tool call parser#444

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
PercyDikec:fix/deepseek-v3-parser-dotall
Mar 6, 2026
Merged

fix: add missing re.DOTALL flag to DeepSeek V3 tool call parser#444
teknium1 merged 1 commit intoNousResearch:mainfrom
PercyDikec:fix/deepseek-v3-parser-dotall

Conversation

@PercyDikec
Copy link
Contributor

What does this PR do?

The DeepSeek V3 tool call parser regex was missing re.DOTALL, so .* couldn't match newlines in the function_arguments capture group. Since tool call JSON arguments are almost always multi-line, the parser silently failed on most real tool calls and returned raw text instead.

Every other parser in the codebase (hermes, mistral, glm45, glm47, qwen3_coder, kimi_k2, longcat) already uses re.DOTALL for their patterns.

Related Issue

Fixes #443

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

  • environments/tool_call_parsers/deepseek_v3_parser.py: Added re.DOTALL flag to PATTERN regex compilation

How to Test

  1. Check every other parser file in environments/tool_call_parsers/ - all use re.DOTALL
  2. Without the flag, this regex only matches single-line JSON: {"query": "hello"}
  3. With the flag, multi-line JSON is matched correctly:
{
  "query": "hello",
  "limit": 5
}

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've tested on my platform: Ubuntu 24.04

Documentation & Housekeeping

  • N/A (one flag added, no docs/config/schema changes)

@teknium1 teknium1 merged commit 936fda3 into NousResearch:main Mar 6, 2026
1 check passed
teknium1 added a commit that referenced this pull request Mar 6, 2026
The V3.1 parser had the same issue — .*? without re.DOTALL fails to
match multi-line JSON arguments. Found during review of PR #444.
@teknium1
Copy link
Contributor

teknium1 commented Mar 6, 2026

Merged in commit 936fda3 🎉 Thanks @PercyDikec!

Also found the same bug in deepseek_v3_1_parser.py — its regex also used .*? without re.DOTALL, so multi-line JSON arguments would fail there too. Fixed in follow-up commit dc55f49.

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.

[Bug]: DeepSeek V3 tool call parser silently drops multi-line JSON arguments

2 participants