DeepSeek/GLM: fix reasoning wire shapes (disable toggle + effort tier) - #598
Merged
Conversation
added 2 commits
July 6, 2026 14:17
Two fixes verified against the live hosted DeepSeek and GLM APIs.
Disable-thinking one-shots (summarizer/critic/approval): the hosted
DeepSeek and GLM APIs only turn reasoning off via {"thinking":{"type":
"disabled"}}; they silently ignore chat_template_kwargs:{thinking:false}
(a vLLM/SGLang self-hosted convention). So the disable was a no-op on
both hosted providers — every one-shot kept emitting reasoning and
paying the latency. Send the thinking toggle for deepseek/glm; keep
chat_template_kwargs for opencode/custom/openrouter (self-hosted).
Reasoning effort (deepseek main loop): DeepSeek honors a top-level
reasoning_effort string but not the nested reasoning:{effort} shape we
were sending (measured: low vs max is a clean ~2x reasoning-token
separation top-level, flat when nested). Give deepseek its own arm that
sends top-level reasoning_effort and can reach the "max" tier (Xhigh),
which OpenAI rejects. openai/glm/custom/openrouter keep the nested
shape; glm ignores effort entirely so it's unchanged.
Closes dirge-r9k8, dirge-f1su.
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.
Two fixes, both empirically verified against the live hosted DeepSeek (
api.deepseek.com) and GLM (open.bigmodel.cn) APIs.1. Disable-thinking one-shots were a no-op on hosted DeepSeek + GLM
reasoning_disable_for_kind(provider/summarize.rs) turns off extended reasoning for the tool-less one-shots (summarizer / critic / approval). It sent{"chat_template_kwargs":{"thinking":false}}for deepseek/glm — but that's the vLLM/SGLang self-hosted convention. The hosted DeepSeek and GLM APIs silently ignore it and disable reasoning only via{"thinking":{"type":"disabled"}}.Measured: with
chat_template_kwargs, deepseek-v4 kept emitting ~130 reasoning tokens (GLM kept reasoning too); withthinking:{type:disabled}, both went to zero. So every summary/title/critic/approval call on hosted deepseek/glm was paying for reasoning it meant to skip (~2× latency).Fix: send the
thinkingtoggle fordeepseek/glm; keepchat_template_kwargsforopencode/custom/openrouter(self-hosted backends).2. DeepSeek reasoning-effort control was near-inert (wrong shape + capped tier)
build_provider_additional_params(agent_loop/rig_stream_factory.rs) sent deepseek a nested{"reasoning":{"effort":…}}and cappedXhigh→"high". Measured on a fixed reasoning prompt:reasoning_effort: low ≈ 384 vs max ≈ 731 reasoning tokens — clean, non-overlapping ~2× separation.reasoning:{effort}: low and max means overlap → effectively ignored.So dirge's effort control for DeepSeek was a near-no-op. Fix: give
deepseekits own arm that sends top-levelreasoning_effortand can reach the"max"tier (Xhigh), which OpenAI rejects.openai/glm/custom/openrouterkeep the nested shape; GLM ignores effort entirely (fixed depth, measured), so it's unchanged.Scope / categorization
Tests: new unit tests for the deepseek effort mapping + top-level-vs-nested shape assertions; existing per-provider tests updated. fmt/clippy clean, full suite green (1 pre-existing flaky h7_glm smoke test unrelated).
Closes dirge-r9k8, dirge-f1su.