Skip to content

feat(model): make DeepSeek thinking_enable tri-state so unset no longer force-sends thinking.type=disabled - #3398

Merged
qbc2016 merged 2 commits into
agentscope-ai:mainfrom
konlue:fix/deepseek-thinking-enable-tristate
Oct 29, 2026
Merged

qbc2016 merged 2 commits into
agentscope-ai:mainfrom
konlue:fix/deepseek-thinking-enable-tristate

Conversation

@konlue

@konlue konlue commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope Version

2.0.10dev (main @ 7c198c5)

Description

DeepSeekChatModel.Parameters.thinking_enable is declared as a non-optional bool with default=False (src/agentscope/model/_deepseek/_model.py:39), and _call_api builds thinking.type unconditionally — so every request carries extra_body["thinking"] = {"type": "disabled"} even when the caller never configured anything. There is no way to express "unset, let the server default apply", which silently disables thinking on DeepSeek hybrid-reasoning models relative to a bare DeepSeek API call.

Changes (mirrors the volcengine model, whose near-identical block at model/_volcengine/_model.py:209-222 is already wrapped in the intended tri-state guard):

  • thinking_enable: bool = Field(default=False, ...) → bool | None = Field(default=None, ...);
  • the request-building block is wrapped in if self.parameters.thinking_enable is not None: — verbatim volcengine style, no new patterns.
caller configuration before after
unset (None) force-sends thinking.type=disabled not sent — server default applies
explicit False sends disabled unchanged
explicit True sends enabled unchanged

Complementary to #3069 (extra_body mutation fix): that PR stopped the caller's thinking dict from being pinned by setdefault; this one stops the unset case from force-sending disabled at all. Same tri-state direction as #3191/#3192 for DashScope. Callers who relied on the old implicit default (nothing configured → thinking disabled) must now pass thinking_enable=False explicitly.

How to test

Regression cases added to the existing tests/model_deepseek_test.py:

  • test_thinking_enable_unset_not_sent — fails on main ('thinking' unexpectedly found in {'thinking': {'type': 'disabled'}}), passes with this fix;
  • test_thinking_enable_explicit_false_sends_disabled / test_thinking_enable_explicit_true_sends_enabled — pin the explicit behavior so it cannot regress;
  • test_extra_body_is_not_mutated updated to pass thinking_enable=False explicitly, keeping its original intent (caller's extra_body is never mutated) under the new tri-state default.
python -m pytest tests/model_deepseek_test.py
# 20 passed.

MoonshotChatModel's non-k3 branch (model/_moonshot/_model.py:211-224) has the same gap — happy to extend this PR or follow up separately, maintainer's preference.

Fixes #3396

Checklist

  • An issue has been created for this PR
  • I have read the CONTRIBUTING.md
  • Docstrings are in Google style
  • Related documentation has been updated (e.g. links, examples, etc.) in documentation repository
  • Code is ready for review

@github-actions github-actions Bot added pr/awaiting-review Waiting for maintainers to review this PR pr/no-linked-issue This PR does not link to any issue labels Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the pull request. One thing worth sorting out before it is reviewed:

  • This pull request does not close an issue. Please open one describing the problem first and link it with Fixes #<number>, so the change can be discussed against the problem it solves.

If you think it belongs here anyway, say so and a maintainer will take a look.

@github-actions github-actions Bot added pr/no-linked-issue This PR does not link to any issue and removed pr/no-linked-issue This PR does not link to any issue labels Oct 21, 2026

@qbc2016 qbc2016 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions Bot removed the pr/awaiting-review Waiting for maintainers to review this PR label Oct 29, 2026
@qbc2016 qbc2016 changed the title fix(model): make DeepSeek thinking_enable tri-state so unset no longer force-sends thinking.type=disabled feat(model): make DeepSeek thinking_enable tri-state so unset no longer force-sends thinking.type=disabled Oct 29, 2026
@qbc2016
qbc2016 merged commit 692db60 into agentscope-ai:main Oct 29, 2026
12 checks passed
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]: DeepSeekChatModel force-sends thinking.type=disabled on every request even when the caller never configured thinking_enable

2 participants