openclaw - 💡(How to fix) Fix Feature: Add clearThinking compat option for Z.AI Preserved Thinking [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#58680Fetched 2026-04-08 01:59:22
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
1
Participants

Fix Action

Workaround

Currently monkey-patching the adapter:

sed -i 's/a\.enable_thinking=!!n?.reasoningEffort;/a.enable_thinking=!!n?.reasoningEffort,a.clear_thinking=!1;/g' \
  /usr/lib/node_modules/openclaw/dist/control-ui/assets/openai-completions-*.js

(This gets overwritten on every openclaw update)

Code Example

{
  "models": {
    "providers": {
      "zai": {
        "api": "openai-completions",
        "baseUrl": "https://open.bigmodel.cn/api/coding/paas/v4",
        "models": [
          {
            "id": "glm-5.1",
            "reasoning": true,
            "compat": {
              "thinkingFormat": "zai",
              "clearThinking": true
            }
          }
        ]
      }
    }
  }
}

---

// Current:
r.thinkingFormat===`zai`&&e.reasoning)a.enable_thinking=!!n?.reasoningEffort;

// Proposed:
if(r.thinkingFormat===`zai`&&e.reasoning){
  a.enable_thinking=!!n?.reasoningEffort;
  if(r.clearThinking)a.clear_thinking=false;
}

---

sed -i 's/a\.enable_thinking=!!n?.reasoningEffort;/a.enable_thinking=!!n?.reasoningEffort,a.clear_thinking=!1;/g' \
  /usr/lib/node_modules/openclaw/dist/control-ui/assets/openai-completions-*.js
RAW_BUFFERClick to expand / collapse

Problem

Z.AI's GLM-5/5.1 models support Preserved Thinking (clear_thinking: false), which retains reasoning_content from previous turns and feeds it back to the model. This improves multi-turn reasoning continuity and enables prompt caching on reasoning tokens.

Currently, OpenClaw's openai-completions adapter sends enable_thinking: true for ZAI provider (when thinkingFormat === 'zai'), but never sends clear_thinking: false.

Proposed Solution

Add a clearThinking option to the compat field for models/providers, so users can enable Preserved Thinking via config:

{
  "models": {
    "providers": {
      "zai": {
        "api": "openai-completions",
        "baseUrl": "https://open.bigmodel.cn/api/coding/paas/v4",
        "models": [
          {
            "id": "glm-5.1",
            "reasoning": true,
            "compat": {
              "thinkingFormat": "zai",
              "clearThinking": true
            }
          }
        ]
      }
    }
  }
}

Code change (minimal)

In openai-completions adapter:

// Current:
r.thinkingFormat===`zai`&&e.reasoning)a.enable_thinking=!!n?.reasoningEffort;

// Proposed:
if(r.thinkingFormat===`zai`&&e.reasoning){
  a.enable_thinking=!!n?.reasoningEffort;
  if(r.clearThinking)a.clear_thinking=false;
}

Impact

  • Z.AI is the only provider that uses clear_thinking
  • No change to existing behavior (default: don't send clear_thinking)
  • Users can opt in via config without source code patches

Workaround

Currently monkey-patching the adapter:

sed -i 's/a\.enable_thinking=!!n?.reasoningEffort;/a.enable_thinking=!!n?.reasoningEffort,a.clear_thinking=!1;/g' \
  /usr/lib/node_modules/openclaw/dist/control-ui/assets/openai-completions-*.js

(This gets overwritten on every openclaw update)

extent analysis

TL;DR

To fix the issue, add a clearThinking option to the compat field in the model configuration and update the openai-completions adapter to send clear_thinking: false when this option is enabled.

Guidance

  • Add a clearThinking option to the model configuration, as shown in the proposed solution, to enable Preserved Thinking for Z.AI models.
  • Update the openai-completions adapter to send clear_thinking: false when clearThinking is enabled, using the proposed code change.
  • Verify that the clear_thinking parameter is being sent correctly by checking the API requests made by the adapter.
  • Consider using the proposed workaround as a temporary solution until the code change can be implemented.

Example

The proposed code change shows how to update the openai-completions adapter to send clear_thinking: false when clearThinking is enabled:

if(r.thinkingFormat===`zai`&&e.reasoning){
  a.enable_thinking=!!n?.reasoningEffort;
  if(r.clearThinking)a.clear_thinking=false;
}

Notes

The workaround provided is temporary and will be overwritten on every openclaw update. A permanent solution requires updating the openai-completions adapter.

Recommendation

Apply the proposed code change to update the openai-completions adapter, as it provides a permanent solution and allows users to opt-in to Preserved Thinking via configuration.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING