Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions agent/transports/chat_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def build_kwargs(
anthropic_max_out = params.get("anthropic_max_output")
is_nvidia_nim = params.get("is_nvidia_nim", False)
is_kimi = params.get("is_kimi", False)
is_zai = params.get("is_zai", False)
reasoning_config = params.get("reasoning_config")

if ephemeral is not None and max_tokens_fn:
Expand Down Expand Up @@ -240,6 +241,16 @@ def build_kwargs(
"type": "enabled" if _kimi_thinking_enabled else "disabled",
}

# Z.AI (GLM) extra_body.thinking — same format as Kimi

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Current main no longer applies registered-provider behavior through this legacy branch: agent/chat_completion_helpers.py:849-888 resolves zai to ZaiProfile, which owns the direct Z.AI wire payload at plugins/model-providers/zai/__init__.py:94-108. Please keep direct Z.AI behavior in that profile rather than add this transport flag.

if is_zai:
_zai_thinking_enabled = True
if reasoning_config and isinstance(reasoning_config, dict):
if reasoning_config.get("enabled") is False:
_zai_thinking_enabled = False
extra_body["thinking"] = {
"type": "enabled" if _zai_thinking_enabled else "disabled",
}

# Reasoning
if params.get("supports_reasoning", False):
if is_github_models:
Expand Down
6 changes: 6 additions & 0 deletions run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7721,6 +7721,10 @@ def _build_api_kwargs(self, api_messages: list) -> dict:
or base_url_host_matches(self.base_url, "moonshot.ai")
or base_url_host_matches(self.base_url, "moonshot.cn")
)
_is_zai = (
base_url_host_matches(self._base_url_lower, "z.ai")
or base_url_host_matches(self._base_url_lower, "open.bigmodel.cn")
)

# Temperature: _fixed_temperature_for_model may return OMIT_TEMPERATURE
# sentinel (temperature omitted entirely), a numeric override, or None.
Expand Down Expand Up @@ -7792,6 +7796,7 @@ def _build_api_kwargs(self, api_messages: list) -> dict:
is_github_models=_is_gh,
is_nvidia_nim=_is_nvidia,
is_kimi=_is_kimi,
is_zai=_is_zai,
is_custom_provider=self.provider == "custom",
ollama_num_ctx=self._ollama_num_ctx,
provider_preferences=_prefs or None,
Expand Down Expand Up @@ -7837,6 +7842,7 @@ def _supports_reasoning_extra_body(self) -> bool:
"anthropic/",
"openai/",
"x-ai/",
"z-ai/",
"google/gemini-2",
"qwen/qwen3",
)
Expand Down
Loading