Introduction

When handling DeepSeek tool calls in DSH, some failures look like “model glitches,” but the root cause might lie in the stitching of requests and responses: tool results have been returned, yet requests might still error out; streaming output looks normal, but the final stitched parameters are not valid JSON; the same history segment behaves differently after toggling thinking on or off.

DeepSeek Protocol Doctor is a third-party DSH plugin used for offline checking of DeepSeek requests, tool loops, reasoning_content, and SSE/JSONL streams. It only checks the given request content or recorded streams; it does not call the model nor judge answer quality.

What is this

DeepSeek Protocol Doctor is maintained by Whning0513 and is under the MIT license. It adds two check tools to DSH:

  • deepseek_protocol_check: Checks requests and message history.
  • deepseek_stream_check: Checks saved SSE/JSONL streams.

It can also be used as an Agent Skill. The repository provides the skills/deepseek-protocol-doctor directory, which DSH can automatically discover from .agents/skills/, .dsh/skills/, and corresponding locations under the user directory. The Skill is only responsible for organizing the troubleshooting steps; the actual protocol checks still call the same dsv4-doctor set.

What problems can be checked

The checklist items listed below are based on currently verified capabilities. The tools mainly target tool calling protocols, streaming response stitching, and common configuration items.

  • Missing tool_call_id.
  • Entering the next round before collecting all tool calls in the current round.
  • reasoning_content being dropped by the client.
  • function.arguments being parsed as JSON before being fully stitched.
  • Multiple streaming tool call deltas arriving interleaved, with the client directly appending them in order of arrival.
  • Strict schema missing required or additionalProperties: false.
  • Related configurations in max_tokens, thinking mode, and the /beta route.

Each issue will have a fixed code, making it easy to handle in CI. Output supports text, JSON, and SARIF. Exit codes can be used to distinguish between error or warning; warnings do not block CI by default, and --fail-on-warning can be added when stricter handling is needed.

Installing to DSH

The plugin requires Python 3.10+. If Python is installed elsewhere, you can set DSV4_DOCTOR_PYTHON.

The following command is used to install the plugin to a specific DSH profile. demo in the command is a profile example and needs to be replaced with the actual profile:

dsh plugin --profile demo add github:Whning0513/deepseek-protocol-doctor

After installation, two new tools will appear in DSH. You can call them directly like this:

用 deepseek_protocol_check 看看这个请求里的工具调用哪里不对:{ ... }

Using as Agent Skill

The skills/deepseek-protocol-doctor in the repository is a Skill directory that DSH can automatically discover. DSH will discover it from .agents/skills/, .dsh/skills/, and corresponding locations under the user directory.

If you want to put the Skill in the shared directory of the current project, you can first execute:

mkdir -p .agents/skills
cp -R /path/to/deepseek-protocol-doctor/skills/deepseek-protocol-doctor .agents/skills/

Replace /path/to/deepseek-protocol-doctor here with the actual local path of the repository. After copying, DSH will still execute checks using the same dsv4-doctor.

Command Line Usage

In the repository directory, you can first create a virtual environment and install:

python3 -m venv .venv
. .venv/bin/activate
python -m pip install -e .

After installation, you can run the sample data:

dsv4-doctor check fixtures/valid_tool_loop.json
dsv4-doctor check fixtures/invalid_tool_loop.json
dsv4-doctor stream fixtures/stream_interleaved.jsonl

If not installed, you can also run directly via the Python module:

PYTHONPATH=src python -m dsv4doctor check fixtures/valid_tool_loop.json

check accepts a complete OpenAI-compatible request and also accepts a standalone messages array; stream accepts SSE and JSONL.

If machine-readable results are needed, you can output JSON or SARIF:

dsv4-doctor check request.json --format json
dsv4-doctor check request.json --format sarif > result.sarif

Applicable Scenarios and Notes

This plugin is suitable for DSH/Agent developers to check request structures, tool loops, and streaming stitching during troubleshooting or CI. It is not a benchmark and does not judge answer quality.

Please note when using:

  • This is a third-party project, not an official DeepSeek component.
  • It does not have a built-in tokenizer and only performs static max_tokens checks, not providing pretend-precise token counts.
  • OpenRouter, vLLM, SGLang, and other compatible interfaces may have their own behaviors, which are not fully covered yet.
  • DSH is still in developer preview; if the upstream plugin interface changes, the wrapper here also needs to be updated accordingly.
  • The tool will not generate a fake reasoning_content for you. This field should save the model’s original return value.
  • The plugin runs with the permissions of the current dsh process; you should check the source code and license before installing.

GitHub Repository: Whning0513/deepseek-protocol-doctor