Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Oct 2, 2025

Description

This PR adds a toggle option to enable/disable thinking mode for Z AI provider models like GLM-4.6 and DeepSeek v3.2, as requested in Issue #8465.

Changes

  • ✨ Added zaiEnableThinking boolean field to provider settings schema
  • 🔧 Updated Z AI provider to conditionally enable thinking mode via the enable_thinking parameter
  • 🎨 Added UI checkbox for thinking mode toggle in Z AI settings component
  • 🌐 Added translation keys for the new UI elements
  • ✅ Added comprehensive tests for thinking mode functionality

Testing

  • All existing tests pass
  • Added 3 new test cases to verify thinking mode behavior:
    • When zaiEnableThinking is true - includes enable_thinking parameter
    • When zaiEnableThinking is false - excludes parameter
    • When zaiEnableThinking is undefined - excludes parameter (default)

Screenshots

The new toggle appears in the Z AI provider settings:

  • Label: "Enable Thinking Mode"
  • Description: "Enable thinking/reasoning mode for models that support it (e.g., GLM-4.6, DeepSeek v3.2). This allows models to show their reasoning process before providing answers."

Related Issues

Fixes #8465

Notes

  • The feature is opt-in and defaults to disabled for backward compatibility
  • The implementation follows existing patterns for provider settings
  • No breaking changes introduced

Important

Add thinking mode toggle for Z AI provider models, updating schema, UI, and tests to support the feature.

  • Behavior:
    • Added zaiEnableThinking boolean field to Z AI provider settings schema in provider-settings.ts.
    • Updated ZAiHandler in zai.ts to include enable_thinking parameter when zaiEnableThinking is true.
    • UI checkbox added in ZAi.tsx for toggling thinking mode.
  • Testing:
    • Added tests in zai.spec.ts to verify enable_thinking parameter behavior for true, false, and undefined cases.
  • Localization:
    • Added translation keys for new UI elements in settings.json.

This description was created by Ellipsis for 04dad30. You can customize this summary. It will automatically update as commits are pushed.

- Add zaiEnableThinking field to provider settings schema
- Update Z AI provider to conditionally enable thinking mode
- Add UI checkbox for thinking mode in Z AI settings component
- Add translation keys for the new UI elements
- Add comprehensive tests for thinking mode functionality

Addresses #8465
@roomote roomote bot requested review from cte, jr and mrubens as code owners October 2, 2025 12:48
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Oct 2, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Self-review: Auditing my own silicon daydreams; statistically unbiased, emotionally unavailable.

ZAI_DEFAULT_TEMPERATURE,
zaiApiLineConfigs,
} from "@roo-code/types"
import { Anthropic } from "@anthropic-ai/sdk"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[P3] Type-only import: This symbol is used purely for types. Importing it as a value pulls in '@anthropic-ai/sdk' at runtime unnecessarily.

Suggested change
import { Anthropic } from "@anthropic-ai/sdk"
import type { Anthropic } from "@anthropic-ai/sdk"


// Add thinking parameter for models that support it (GLM-4.6, etc.)
// Only add if explicitly enabled via the zaiEnableThinking setting
if (this.options.zaiEnableThinking === true) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[P2] Scope 'enable_thinking' to supported models. As written, any model will receive the flag when the setting is on, which can trigger 400s for models that don't implement thinking mode. Consider gating by model id (e.g., /^glm-4.6/) or a capability map so unsupported models are unaffected.

<div>
<VSCodeCheckbox
checked={apiConfiguration?.zaiEnableThinking || false}
onChange={handleCheckboxChange("zaiEnableThinking")}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[P3] Event-driven checkbox: Flipping based on current state can race with queued updates in React. Prefer using the event's checked value to set an explicit boolean, e.g. onChange={(e) => setApiConfigurationField('zaiEnableThinking', (e.target as HTMLInputElement).checked)}.

"zaiEntrypoint": "Z AI Entrypoint",
"zaiEntrypointDescription": "Please select the appropriate API entrypoint based on your location. If you are in China, choose open.bigmodel.cn. Otherwise, choose api.z.ai.",
"zaiEnableThinking": "Enable Thinking Mode",
"zaiEnableThinkingDescription": "Enable thinking/reasoning mode for models that support it (e.g., GLM-4.6, DeepSeek v3.2). This allows models to show their reasoning process before providing answers.",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[P2] Provider-specific copy: This toggle is under the Z AI provider. Mentioning DeepSeek here can confuse users. Suggest: "Enable thinking/reasoning mode for supported Z AI models (e.g., GLM-4.6). This allows models to show their reasoning process before providing answers."

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 2, 2025
@Eastonboy99
Copy link

I did a little digging into these and found out the following:

  1. The parameter to enable thinking is:
"thinking":{
    "type": "enabled"
}

Instead of enable_thinking = true.

  1. The content returned is found in reasoning_content for thinking and content for anything else. Both can exist in the delta at the same time and either can be an empty string

  2. Even with thinking enabled, the api seems to care what the message you send is. If I remove the system prompt and the part of the message with the environment details, current time, etc, then I will get reasoning messages back (meaning I only send the task message). Otherwise, reasoning messages are not returned. I'm not sure why but that is what I found.

@daniel-lxs
Copy link
Member

This is not a proper fix

@daniel-lxs daniel-lxs closed this Oct 27, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 27, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Oct 27, 2025
@daniel-lxs daniel-lxs deleted the feat/zai-thinking-mode-toggle branch October 27, 2025 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] we should have a choice on “thinking enable”when choose Z AI as model provider

5 participants