openclaw - 💡(How to fix) Fix Session bootstrap race condition sends zero messages to zai/glm-5.1 causing 400 error [2 comments, 3 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#73683Fetched 2026-04-29 06:16:26
View on GitHub
Comments
2
Participants
3
Timeline
2
Reactions
0
Author
Timeline (top)
commented ×2

Error Message

Models that tolerate a system-only request (e.g., bailian/qwen3.6-plus) succeed. But models that require at least one non-system message (e.g., zai/glm-5.1, zai/glm-5-turbo) reject the request with a 400 error: I confirmed the error is reproducible with direct API calls:

Only system message -> 400 (matches the log error exactly)

-> {"error":{"code":"1214","message":"messages 参数非法。请检查文档。"}}

Empty messages array -> different error

-> {"error":{"code":"1214","message":"输入不能为空"}}

Root Cause

I traced through the trajectory files of 5 failed session boots. Every single one shows the same pattern:

RAW_BUFFERClick to expand / collapse

Bug Description

When a new webchat session starts, the first API request to the LLM provider is sent before the bootstrap user message is written to the session file. This results in prompt.submitted having messages: [] (zero conversation messages, only a system prompt).

Models that tolerate a system-only request (e.g., bailian/qwen3.6-plus) succeed. But models that require at least one non-system message (e.g., zai/glm-5.1, zai/glm-5-turbo) reject the request with a 400 error:

400 messages 参数非法。请检查文档。

After the initial failure, the bootstrap message is written to the session file, and subsequent fallback requests succeed.

Steps to Reproduce

  1. Configure zai provider with a GLM-5.1 or GLM-5-Turbo model as the primary model
  2. Start a new webchat session (/new or /reset)
  3. Observe that the first API request fails with 400, then fallback succeeds

Root Cause Analysis

I traced through the trajectory files of 5 failed session boots. Every single one shows the same pattern:

Trajectory evidence

Failed request (zai/glm-5.1):

prompt.submitted -> messages=0, system_prompt_len=49637

The prompt.submitted event confirms the request was sent with zero conversation messages. After the failure, the bootstrap messages are written, and the fallback request sees them.

Confirmed affected sessions

Time (UTC)Session FileModelprompt.submitted messagesResult
2026-04-28 14:14:223eb9302fglm-5.10400
2026-04-28 15:24:106c5dfb28glm-5.10400
2026-04-28 15:49:150a26d71fglm-5.10400
2026-04-28 16:02:5924c66d4cglm-5-turbo0400
2026-04-28 16:06:24e5421c47glm-5.10400

Successful comparison

The same session that failed for glm-5.1 at 23:49 later succeeded with glm-5-turbo at 00:01 with 63 messages (after bootstrap messages were written).

API endpoint verification

I confirmed the error is reproducible with direct API calls:

# Only system message -> 400 (matches the log error exactly)
curl ... -d "{\"model\":\"glm-5.1\",\"messages\":[{\"role\":\"system\",\"content\":\"You are an assistant.\"}]}"
# -> {"error":{"code":"1214","message":"messages 参数非法。请检查文档。"}}

# With user message -> 200 OK
curl ... -d "{\"model\":\"glm-5.1\",\"messages\":[{\"role\":\"system\",\"content\":\"You are an assistant.\"},{\"role\":\"user\",\"content\":\"hello\"}]}"
# -> 200 OK

# Empty messages array -> different error
curl ... -d "{\"model\":\"glm-5.1\",\"messages\":[]}"
# -> {"error":{"code":"1214","message":"输入不能为空"}}

The zai Coding Plan endpoint requires at least one user or assistant message. The bug is on the OpenClaw side sending the request before bootstrap messages exist.

Why it was not noticed before

  1. Model tolerance: Previously used models like bailian/qwen3.6-plus accept system-only requests and generate a greeting.
  2. glm-4.7 tolerance: GLM-4.7 on the same Coding Plan endpoint may also be more lenient.
  3. glm-5.1/5-turbo strictness: These newer models enforce a stricter messages schema.

Suggested Fix

Ensure the bootstrap user message is written to the session file before the first API request is made. Options:

  1. Pre-write bootstrap message: Write (session bootstrap) during session.started handling, before the first prompt.submitted.
  2. Synthetic bootstrap message: If the session file is empty at request time, inject a synthetic user message into the messages array sent to the provider.
  3. Await bootstrap completion: Ensure the first API request waits for the bootstrap message write to complete.

Environment

  • OpenClaw version: v2026.4.26 (be8c246)
  • Node.js: v24.15.0
  • OS: macOS 24.6.0 (arm64)
  • Channel: webchat
  • Provider: zai (Coding Plan endpoint: https://open.bigmodel.cn/api/coding/paas/v4)
  • Models affected: zai/glm-5.1, zai/glm-5-turbo
  • Models unaffected (tolerate system-only): bailian/qwen3.6-plus

extent analysis

TL;DR

Ensure the bootstrap user message is written to the session file before the first API request is made to the LLM provider.

Guidance

  • Verify that the session file is being written to correctly and that the bootstrap message is being generated as expected.
  • Consider implementing one of the suggested fixes, such as pre-writing the bootstrap message, injecting a synthetic user message, or awaiting bootstrap completion.
  • Test the fix with the affected models (zai/glm-5.1 and zai/glm-5-turbo) to ensure that the issue is resolved.
  • Review the API endpoint verification steps to understand how the error is reproducible and how the fix should be implemented.

Example

No code snippet is provided as the issue does not require a specific code change, but rather a change in the order of operations or the addition of a new step to ensure the bootstrap message is written before the API request.

Notes

The fix may need to be adapted based on the specific implementation details of the OpenClaw system and the zai provider. Additionally, testing with other models and scenarios may be necessary to ensure that the fix does not introduce any new issues.

Recommendation

Apply a workaround, such as pre-writing the bootstrap message or injecting a synthetic user message, to ensure that the bootstrap user message is written to the session file before the first API request is made. This will allow the system to function correctly with the affected models.

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 Session bootstrap race condition sends zero messages to zai/glm-5.1 causing 400 error [2 comments, 3 participants]