openclaw - 💡(How to fix) Fix [Bug] /new session creation fails with ZAI/GLM: provider rejects system-only messages (400) [2 comments, 2 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#73688Fetched 2026-04-29 06:16:19
View on GitHub
Comments
2
Participants
2
Timeline
3
Reactions
0
Timeline (top)
commented ×2closed ×1

Error Message

embedded run agent end: LLM request failed: provider rejected the request schema or tool payload. rawError: 400 The messages parameter is illegal. Please check the documentation. providerRuntimeFailureKind: schema failoverReason: format

Root Cause

The ZAI/GLM API (https://api.z.ai/api/coding/paas/v4/chat/completions) rejects requests where the messages array contains only a system message without a trailing user message (HTTP 400, error code 1214). The same rejection occurs for assistant messages with empty content.

When /new creates a fresh session, OpenClaw constructs the initial LLM request with the full system prompt (workspace context files, agent config, skills, etc.) but apparently does not include a valid user message in the messages array — or includes an empty one. The ZAI API rejects this payload before the model can respond.

Fix Action

Workaround

Setting a per-session model override to a non-ZAI provider (e.g., via /model) avoids the issue for existing sessions, but /new still fails because it creates a new session with the default model (zai/glm-5.1).

Code Example

⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session.

---

embedded run agent end: LLM request failed: provider rejected the request schema or tool payload.
rawError: 400 The messages parameter is illegal. Please check the documentation.
providerRuntimeFailureKind: schema
failoverReason: format

---

{
  "model": "glm-5.1",
  "messages": [{"role": "system", "content": "You are a helpful assistant."}],
  "max_tokens": 10,
  "thinking": {"type": "disabled"}
}

---

{
  "model": "glm-5.1",
  "messages": [
    {"role": "system", "content": "You are helpful."},
    {"role": "assistant", "content": ""}
  ],
  "max_tokens": 10,
  "thinking": {"type": "disabled"}
}

---

{
  "model": "glm-5.1",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "hi"}
  ],
  "max_tokens": 10,
  "thinking": {"type": "disabled"}
}

---

2026-04-28T18:06:05.043+02:00 [diagnostic] stuck session: sessionId=unknown sessionKey=agent:main:telegram:slash:5868868997 state=processing age=168s queueDepth=1

2026-04-28T18:06:07.152+02:00 [agent/embedded] embedded run agent end: runId=38f7cd2a-77c5-4f4a-9c76-3c0b0e62bba5 isError=true model=glm-5.1 provider=zai error=LLM request failed: provider rejected the request schema or tool payload. rawError=400 The messages parameter is illegal. Please check the documentation.

2026-04-28T18:06:07.177+02:00 [agent/embedded] embedded run failover decision: runId=38f7cd2a-77c5-4f4a-9c76-3c0b0e62bba5 stage=assistant decision=surface_error reason=format from=zai/glm-5.1 profile=sha256:118886372c36 rawError=400 The messages parameter is illegal. Please check the documentation.
RAW_BUFFERClick to expand / collapse

Bug Description

/new slash command and fresh session creation fails with ZAI (GLM) provider when the default model is any GLM variant (glm-5.1, glm-5-turbo, etc.). The error surfaces as:

⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session.

The gateway logs show:

embedded run agent end: LLM request failed: provider rejected the request schema or tool payload.
rawError: 400 The messages parameter is illegal. Please check the documentation.
providerRuntimeFailureKind: schema
failoverReason: format

Root Cause

The ZAI/GLM API (https://api.z.ai/api/coding/paas/v4/chat/completions) rejects requests where the messages array contains only a system message without a trailing user message (HTTP 400, error code 1214). The same rejection occurs for assistant messages with empty content.

When /new creates a fresh session, OpenClaw constructs the initial LLM request with the full system prompt (workspace context files, agent config, skills, etc.) but apparently does not include a valid user message in the messages array — or includes an empty one. The ZAI API rejects this payload before the model can respond.

Direct API Reproduction

All three scenarios return 400 {"error":{"code":"1214","message":"The messages parameter is illegal. Please check the documentation."}}:

1. System-only messages (the /new scenario):

{
  "model": "glm-5.1",
  "messages": [{"role": "system", "content": "You are a helpful assistant."}],
  "max_tokens": 10,
  "thinking": {"type": "disabled"}
}

2. Empty assistant content:

{
  "model": "glm-5.1",
  "messages": [
    {"role": "system", "content": "You are helpful."},
    {"role": "assistant", "content": ""}
  ],
  "max_tokens": 10,
  "thinking": {"type": "disabled"}
}

3. Null/missing user content also rejected (code 1210/1213).

Control (works correctly):

{
  "model": "glm-5.1",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "hi"}
  ],
  "max_tokens": 10,
  "thinking": {"type": "disabled"}
}

→ Returns 200 with valid response.

Affected Models

Tested and confirmed on both glm-5.1 and glm-5-turbo. Likely affects all GLM models on the ZAI Coding Plan endpoint (/api/coding/paas/v4).

Environment

ComponentValue
OpenClaw2026.4.26 (be8c246)
Node.jsv22.22.2
OSUbuntu 24.04 LTS (kernel 6.8.0-110-generic, x64)
ProviderZAI (zai)
Endpointhttps://api.z.ai/api/coding/paas/v4 (Coding Plan Global)
API typeopenai-completions
Default modelzai/glm-5.1
ChannelTelegram (DM)

Gateway Log Evidence

2026-04-28T18:06:05.043+02:00 [diagnostic] stuck session: sessionId=unknown sessionKey=agent:main:telegram:slash:5868868997 state=processing age=168s queueDepth=1

2026-04-28T18:06:07.152+02:00 [agent/embedded] embedded run agent end: runId=38f7cd2a-77c5-4f4a-9c76-3c0b0e62bba5 isError=true model=glm-5.1 provider=zai error=LLM request failed: provider rejected the request schema or tool payload. rawError=400 The messages parameter is illegal. Please check the documentation.

2026-04-28T18:06:07.177+02:00 [agent/embedded] embedded run failover decision: runId=38f7cd2a-77c5-4f4a-9c76-3c0b0e62bba5 stage=assistant decision=surface_error reason=format from=zai/glm-5.1 profile=sha256:118886372c36 rawError=400 The messages parameter is illegal. Please check the documentation.

The error is persistent — every /new attempt fails with the same error. The session gets stuck for ~170s before surfacing the error to the user.

Workaround

Setting a per-session model override to a non-ZAI provider (e.g., via /model) avoids the issue for existing sessions, but /new still fails because it creates a new session with the default model (zai/glm-5.1).

Suggested Fix

OpenClaw should ensure that the messages array sent to the LLM API always contains at least one non-empty user message after the system message(s). This could be:

  1. Append a placeholder user message (e.g., the /new command text itself or a minimal initialization prompt) when constructing the initial request for a fresh session.
  2. Validate the messages array before sending to providers known to reject system-only payloads, and inject a synthetic user turn if needed.
  3. Provider-level message sanitization in the ZAI/OpenAI-completions adapter to strip or pad messages that would trigger this rejection.

extent analysis

TL;DR

Ensure the messages array sent to the ZAI LLM API contains at least one non-empty user message after the system message to fix the /new slash command failure.

Guidance

  • Verify that the messages array is correctly constructed for fresh sessions, including a valid user message.
  • Consider appending a placeholder user message (e.g., the /new command text) when constructing the initial request.
  • Validate the messages array before sending to providers known to reject system-only payloads and inject a synthetic user turn if needed.
  • Review the ZAI/OpenAI-completions adapter for potential provider-level message sanitization to handle rejected payloads.

Example

{
  "model": "glm-5.1",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "/new"}  // Append a placeholder user message
  ],
  "max_tokens": 10,
  "thinking": {"type": "disabled"}
}

Notes

The suggested fix assumes that the issue is specific to the ZAI provider and the /new slash command. Further testing may be necessary to confirm the root cause and effectiveness of the proposed solution.

Recommendation

Apply a workaround by appending a placeholder user message to the messages array for fresh sessions, as this is a straightforward and targeted solution to address the rejection issue with the ZAI LLM API.

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

openclaw - 💡(How to fix) Fix [Bug] /new session creation fails with ZAI/GLM: provider rejects system-only messages (400) [2 comments, 2 participants]