Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 22, 2025

Related GitHub Issue

Closes: #10269

Roo Code Task Context (Optional)

N/A

Description

This PR adds support for the GLM-4.7 model with preserved thinking capabilities to the Z.ai provider, as requested in issue #10269.

Changes made:

  1. Added GLM-4.7 documentation links to the file header comments:

  2. Added glm-4.7 entry to internationalZAiModels with:

    • maxTokens: 98,304
    • contextWindow: 200,000
    • supportsPromptCache: true
    • supportsNativeTools: true
    • defaultToolProtocol: "native"
    • preserveReasoning: true (enables interleaved thinking mode)
    • Pricing aligned with GLM-4.6
  3. Added glm-4.7 entry to mainlandZAiModels with similar configuration but using mainland China pricing

  4. Added tests to verify the GLM-4.7 model has preserveReasoning enabled for both international and China endpoints

How preserved thinking works:

The preserveReasoning: true flag enables interleaved thinking mode for tool calls. When enabled:

  • The model returns reasoning_content alongside regular content
  • This reasoning content is passed back in subsequent requests during tool call continuation
  • This helps preserve reasoning continuity, improves model performance, and increases cache hit rates

This follows the existing pattern used for DeepSeek reasoner models and aligns with the Z.ai documentation on thinking mode.

Test Procedure

  • Verified TypeScript compilation passes: cd packages/types && npx tsc --noEmit
  • Verified linting passes: pnpm lint
  • Verified unit tests pass: cd src && npx vitest run api/providers/__tests__/zai.spec.ts (29 tests passed)
  • Added new tests for GLM-4.7 preserved thinking support in both international and China endpoints

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A - This is a data/configuration change only.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This PR attempts to address Issue #10269 by adding GLM-4.7 with preserved thinking support as requested by @kavehsfv. The existing infrastructure already handles reasoning_content in streaming responses via the BaseOpenAiCompatibleProvider, so no additional handler changes were needed.

Feedback and guidance are welcome!

@roomote
Copy link
Contributor Author

roomote bot commented Dec 22, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

This PR correctly adds GLM-4.7 model support with preserved thinking capabilities to both international and mainland Z.ai endpoints. The implementation follows existing patterns, uses valid schema fields, and includes appropriate test coverage.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Add support for GLM-4.7 on Z.ai Provider

3 participants