fix(agent): enable reasoning_content for Z.AI/GLM models#16592
Open
vominh1919 wants to merge 1 commit into
Open
fix(agent): enable reasoning_content for Z.AI/GLM models#16592vominh1919 wants to merge 1 commit into
vominh1919 wants to merge 1 commit into
Conversation
Z.AI/GLM models use the thinking parameter (same format as Kimi) to enable chain-of-thought reasoning. The existing code only injected the OpenRouter-style reasoning extra_body, which Z.AI silently ignores. - Add _is_zai URL detection for z.ai and open.bigmodel.cn - Add is_zai parameter to chat_completions transport - Add Z.AI thinking extra_body injection (mirrors Kimi pattern) - Add z-ai/ to OpenRouter reasoning_model_prefixes Fixes NousResearch#16533
Collaborator
|
Likely duplicate of #11494 — both add preserved thinking support for Z.AI/GLM models via extra_body.thinking parameter injection. |
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.
Fixes #16533
Problem
Z.AI/GLM models (glm-5.1, glm-4.7, etc.) never return
reasoning_content— even on questions that clearly trigger chain-of-thought when the same model is hit directly via cURL.Root Cause
Z.AI's API uses the
thinkingparameter (same format as Kimi) to enable reasoning:But Hermes only injected the OpenRouter-style
reasoningextra_body, which Z.AI silently ignores. There was no Z.AI-specific handling in the reasoning pipeline.Fix
Three changes across 2 files:
run_agent.py— Add_is_zaiURL detection forz.aiandopen.bigmodel.cnhosts, passis_zaiflag to transportrun_agent.py— Add"z-ai/"to OpenRouterreasoning_model_prefixesso Z.AI models get reasoning via OpenRouterchat_completions.py— Add Z.AIthinkingextra_body injection, mirroring the existing Kimi patternFiles Changed
run_agent.py— 8 lines added (Z.AI detection + OpenRouter prefix)agent/transports/chat_completions.py— 11 lines added (thinking extra_body)