Skip to content

DeepSeek/GLM: fix reasoning wire shapes (disable toggle + effort tier) - #598

Merged
yogthos merged 2 commits into
mainfrom
deepseek-reasoning-improvements
Jul 6, 2026
Merged

DeepSeek/GLM: fix reasoning wire shapes (disable toggle + effort tier)#598
yogthos merged 2 commits into
mainfrom
deepseek-reasoning-improvements

Conversation

@yogthos

@yogthos yogthos commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

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); with thinking:{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 thinking toggle for deepseek/glm; keep chat_template_kwargs for opencode/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 capped Xhigh→"high". Measured on a fixed reasoning prompt:

  • top-level reasoning_effort: low ≈ 384 vs max ≈ 731 reasoning tokens — clean, non-overlapping ~2× separation.
  • nested reasoning:{effort}: low and max means overlap → effectively ignored.

So dirge's effort control for DeepSeek was a near-no-op. Fix: 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 (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.

Yogthos 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.
@yogthos
yogthos merged commit c34eae3 into main Jul 6, 2026
13 checks passed
@yogthos
yogthos deleted the deepseek-reasoning-improvements branch July 6, 2026 18:25
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.

1 participant