Tabbit
ResourcesBlogModels
Tabbit LogoTabbit

Tabbit — The AI Browser that Works for You

Topics

  • AI Browser Resources
  • Agentic Browser Resources
  • Browser Downloads and Install Guides
  • Browser Comparisons
  • AI Browser Alternatives
  • Browser Productivity Resources

Popular Guides

  • AI Browser
  • Agentic Browser Download
  • Best AI Browser 2026: Top 9 Tested & Ranked
  • AI Browser Download
  • Free AI Browser
  • Best AI Browser 2026
  • AI Browser Comparison 2026
  • AI Browser for Windows
  • AI Browser for Mac
  • Chrome Alternative 2026

Events

  • Tabbit Skill Competition
  • KPOP SBTI Fandom Personality Test
  • Tabbit Campus Creator Program
  • fifi's Picks: AI Skills for Research Papers
  • User Survey

About

  • Tabbit Blog
  • Press & Media
Prompt guide
MediaGLM-5.2

GLM-5.2 Thinking Mode Configuration: Default Thinking / Interleaved Thinking / Preserved Thinking / Turn-level Thinking (Official)

Original source

Z.ai Official Developer Documentation (docs.z.ai, Capabilities / Thinking Mode)

AuthorZ.ai (Zhipu AI International)

Tabbit curation2026-08-19

Read original

One-sentence takeaway

The official documentation states that thinking is enabled by default for GLM-5.2 (as with GLM-5.1/5/4.7), and provides four thinking modes: default thinking, interleaved thinking (thinking between tool calls), preserved thinking (retaining reasoning content across turns with clear_thinking: false), and turn-level thinking (an independent switch for each turn). It also highlights a key constraint for Agent integrations: historical reasoning_content must be returned unchanged.

Use cases

  • Suitable tasks: building tool-calling Agents (which need to continue reasoning after each tool result); coding/Agent products that prioritize consistency in long sessions and cache hit rates (preserved thinking); multi-turn applications that need fine-grained per-turn control over cost and latency (turn-level thinking).

  • Unsuitable tasks: session systems that cannot or do not want to return complete reasoning_content (this will break preserved thinking and reduce performance and cache hits); forwarding layers with privacy or compliance concerns about thinking content (thinking is enabled by default and cannot be globally disabled without changing behavior).

  • Supported model versions: GLM-5.2, GLM-5.1, GLM-5, and GLM-4.7 (thinking enabled by default); GLM-4.6 uses hybrid thinking by default and behaves differently.

  • Supported clients, Agents, or APIs: the Z.ai Chat Completions API; the GLM Coding Plan endpoint (preserved thinking enabled by default); standard API endpoints (preserved thinking disabled by default and must be explicitly enabled with "clear_thinking": false).

  • Recommended reasoning mode and parameters: thinking enabled by default; thinking.type supports enabled / disabled; for Agent scenarios, use "clear_thinking": false (preserved thinking) and return the complete, unmodified reasoning_content; for lightweight turns, use thinking.type: disabled for faster responses.

Ready-to-use content

Disable thinking (official syntax)

"thinking": {
    "type": "disabled"
}

Preserved Thinking configuration essentials

  • Recommended for coding/Agent scenarios; enabled by default for Coding Plan endpoints and disabled by default for standard API endpoints.

  • How to enable it (API endpoints): "clear_thinking": false.

  • The complete, unmodified reasoning_content must be returned to the API; all consecutive reasoning blocks must remain in exactly the same order in which the model originally generated them and must not be reordered or edited. Otherwise, performance will decline and cache hits will be affected.

  • Effect: retains the previous assistant turn's reasoning content in the context, maintains reasoning continuity, improves performance, and increases cache hits to save tokens.

Interleaved Thinking + complete tool-calling example (official)

"""Interleaved Thinking + Tool Calling Example"""

import json
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.z.ai/api/paas/v4/",
)

tools = [{"type": "function", "function": {
    "name": "get_weather",
    "description": "Get weather information",
    "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
}}]

messages = [
    {"role": "system", "content": "You are an assistant"},
    {"role": "user", "content": "What's the weather like in Beijing?"},
]

# Round 1: the model reasons and then calls a tool
response = client.chat.completions.create(model="glm-5.2", messages=messages, tools=tools, stream=True, extra_body={
        "thinking":{
        "type":"enabled",
        "clear_thinking": False  # False for Preserved Thinking
    }})
reasoning, content, tool_calls = "", "", []
for chunk in response:
    delta = chunk.choices[0].delta
    if hasattr(delta, "reasoning_content") and delta.reasoning_content:
        reasoning += delta.reasoning_content
    if hasattr(delta, "content") and delta.content:
        content += delta.content
    if hasattr(delta, "tool_calls") and delta.tool_calls:
        for tc in delta.tool_calls:
            if tc.index >= len(tool_calls):
                tool_calls.append({"id": tc.id, "function": {"name": "", "arguments": ""}})
            if tc.function.name:
                tool_calls[tc.index]["function"]["name"] = tc.function.name
            if tc.function.arguments:
                tool_calls[tc.index]["function"]["arguments"] += tc.function.arguments

print(f"Reasoning: {reasoning}\nTool calls: {tool_calls}")

# Key: return reasoning_content to keep the reasoning coherent
messages.append({"role": "assistant", "content": content, "reasoning_content": reasoning,
                 "tool_calls": [{"id": tc["id"], "type": "function", "function": tc["function"]} for tc in tool_calls]})
messages.append({"role": "tool", "tool_call_id": tool_calls[0]["id"],
                 "content": json.dumps({"weather": "Sunny", "temp": "25°C"})})

# Round 2: the model continues reasoning based on the tool result and responds
response = client.chat.completions.create(model="glm-5.2", messages=messages, tools=tools, stream=True, extra_body={
        "thinking":{
        "type":"enabled",
        "clear_thinking": False # False for Preserved Thinking
    }})
reasoning, content = "", ""
for chunk in response:
    delta = chunk.choices[0].delta
    if hasattr(delta, "reasoning_content") and delta.reasoning_content:
        reasoning += delta.reasoning_content
    if hasattr(delta, "content") and delta.content:
        content += delta.content

print(f"Reasoning: {reasoning}\nReply: {content}")

Turn-level Thinking essentials

  • Within the same session, each request can independently choose whether to enable or disable thinking.

  • For lightweight turns (fact lookup, wording edits), disable thinking for faster responses; for demanding tasks (complex planning, multi-constraint reasoning, code debugging), enable thinking for greater accuracy and stability.

  • Agent/tool scenarios: reduce reasoning overhead for turns that need to execute tools quickly, and deepen thinking for turns that need to make decisions based on tool results.

  • Across multiple turns, the model maintains coherent, consistent output style.

Notes and limitations

  • The example code in the official documentation uses model="glm-4.7" as a generic documentation example; the same page clearly states that the default-enabled thinking behavior applies to the GLM-5.2 series. When integrating GLM-5.2, change it to model="glm-5.2".

  • The requirement to return reasoning_content verbatim for preserved thinking is a hard requirement for forwarding layers and intermediate caches. Failure to meet it will directly harm performance.

Curated by Tabbit

Prompt material is summarized from public sources and Tabbit editorial notes. Check the original licensing and intended use before copying it.

GLM-5.2

Use in Tabbit

GLM-5.2

Related prompts

MediaZ.ai official developer documentation (docs.z.ai)2026-06-16

GLM-5.2 Official Documentation: Overview and API Quick Start (docs.z.ai)

MediaZ.ai official developer documentation (docs.z.ai, Get Started / Migrate)2026-06

Official Configuration Guide for Migrating from GLM-5.1 / GLM-5 / GLM-4.x to GLM-5.2

CommunityX.com (Twitter), @arena (official Arena.ai account)2026-06-27

Arena.ai Frontend Coding Head-to-Head: 10 Single-shot Generation Examples Comparing GLM-5.2 (Max) and Claude Opus 4.8 (Thinking)

Mediarentry.org (the author's self-hosted prompt library, recommended by the SillyTavernAI community)2026-08-07

GLM-5.2 Role-Playing (RP) System Prompt: Evening-Truth Complete Dark-Version Prompt

GLM-5.2

Related reviews

OfficialZ.ai official blog2026-06-16

GLM-5.2 Official Release Notes and Complete Benchmark Table (Z.ai Blog)

MediaNIST (National Institute of Standards and Technology) official news site2026-07-17

NIST CAISI's Independent Capability Assessment of Z.ai GLM-5.2

Mediarentry.org (a page describing the author's personal prompt library)2026-03-09

Evening-Truth's Complaints About Z.AI Coding Plan Response Quality and Quantization Suspicions

MediaHugging Face official blog (Security incident disclosure)2026-07

Hugging Face Security Incident Forensics: GLM-5.2 Used for Self-Hosted Attack Log Analysis (Real-World Project Report)