openclaw - 💡(How to fix) Fix openai/gpt-5.4: Command lane cleared on every message in channel sessions (WS session interrupted mid-turn) [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#56871Fetched 2026-04-08 01:46:44
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

When using openai/gpt-5.4 as the default model in a Discord channel session, the agent fails before reply with:

⚠️ Agent failed before reply: Command lane "session:agent:main:discord:channel:<channelId>" cleared.

The model fallback chain fires (gpt-5.4gemini-3.1-pro-preview) but both fail with the same cleared-lane error, leaving the channel unable to respond.

Error Message

The model fallback chain fires (gpt-5.4gemini-3.1-pro-preview) but both fail with the same cleared-lane error, leaving the channel unable to respond. 4. Agent fails before reply; channel shows the ⚠️ Agent failed before reply error 2026-03-29T07:53:55.717Z warn model-fallback/decision candidate_failed requestedModel=gpt-5.4 errorPreview="Command lane 'session:agent:main:discord:channel:1485311563157213258' cleared" 2026-03-29T07:55:07.021Z error Embedded agent failed before reply: Command lane "session:agent:main:discord:channel:1485311563157213258" cleared The error occurs consistently across multiple message attempts. The channel recovers only after a context compaction event resets the session. {"error": {"message": "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead."}}

Root Cause

Root cause investigation

Code Example

⚠️ Agent failed before reply: Command lane "session:agent:main:discord:channel:<channelId>" cleared.

---

2026-03-29T07:53:55.717Z warn model-fallback/decision candidate_failed requestedModel=gpt-5.4 errorPreview="Command lane 'session:agent:main:discord:channel:1485311563157213258' cleared"
2026-03-29T07:55:07.021Z error Embedded agent failed before reply: Command lane "session:agent:main:discord:channel:1485311563157213258" cleared

---

{"error": {"message": "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead."}}

---

// onboard-custom-DY0XuRoF.js:233
max_tokens: 1,

// onboard-iE_s6O7s.js:209  
max_tokens: 1

---

// shared-x9RbOMks.js (Foundry-specific, line 17)
function requiresFoundryMaxCompletionTokens(value) {
  const normalized = normalizeFoundryModelName(value);
  if (!normalized) return false;
  return normalized.startsWith("gpt-5") || normalized.startsWith("o1") || 
         normalized.startsWith("o3") || normalized.startsWith("o4");
}
RAW_BUFFERClick to expand / collapse

Summary

When using openai/gpt-5.4 as the default model in a Discord channel session, the agent fails before reply with:

⚠️ Agent failed before reply: Command lane "session:agent:main:discord:channel:<channelId>" cleared.

The model fallback chain fires (gpt-5.4gemini-3.1-pro-preview) but both fail with the same cleared-lane error, leaving the channel unable to respond.

Reproduction

  1. Configure agents.defaults.model.primary = "openai/gpt-5.4"
  2. Set up a Discord channel session (not the main session channel)
  3. Send any message to that channel
  4. Agent fails before reply; channel shows the ⚠️ Agent failed before reply error

Log evidence

2026-03-29T07:53:55.717Z warn model-fallback/decision candidate_failed requestedModel=gpt-5.4 errorPreview="Command lane 'session:agent:main:discord:channel:1485311563157213258' cleared"
2026-03-29T07:55:07.021Z error Embedded agent failed before reply: Command lane "session:agent:main:discord:channel:1485311563157213258" cleared

The error occurs consistently across multiple message attempts. The channel recovers only after a context compaction event resets the session.

Root cause investigation

During investigation, I confirmed that hitting the OpenAI Chat Completions API directly with gpt-5.4 using max_tokens fails with:

{"error": {"message": "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead."}}

OpenClaw correctly routes openai/gpt-5.4 to api: "openai-responses" (Responses API, not Chat Completions), so the max_tokens issue does not apply to the normal streaming path. However, the onboard-*.js probe calls and fallback model resolution paths still send max_tokens: 1 to Chat Completions endpoints during model validation/probe steps:

// onboard-custom-DY0XuRoF.js:233
max_tokens: 1,

// onboard-iE_s6O7s.js:209  
max_tokens: 1

These probe calls fail for gpt-5.4, which may be causing the channel lane to be marked as invalid before the actual response turn begins.

Suggested fix

In the model probe/onboard paths, check if the model requires max_completion_tokens instead of max_tokens. The logic already exists in shared-x9RbOMks.js (requiresFoundryMaxCompletionTokens) for the Foundry provider — it should be extracted and shared:

// shared-x9RbOMks.js (Foundry-specific, line 17)
function requiresFoundryMaxCompletionTokens(value) {
  const normalized = normalizeFoundryModelName(value);
  if (!normalized) return false;
  return normalized.startsWith("gpt-5") || normalized.startsWith("o1") || 
         normalized.startsWith("o3") || normalized.startsWith("o4");
}

A shared requiresMaxCompletionTokens(modelId) helper should be used in:

  • onboard-custom-DY0XuRoF.js (probe calls)
  • onboard-iE_s6O7s.js (probe calls)
  • Any other Chat Completions request builder that currently hardcodes max_tokens

Environment

  • OpenClaw version: 2026.3.13
  • Model: openai/gpt-5.4
  • Channel type: Discord guild channel (non-main session)
  • OS: macOS Darwin 25.3.0 arm64

extent analysis

Fix Plan

To resolve the issue, we need to update the model probe and onboard paths to use max_completion_tokens instead of max_tokens for models that require it.

Here are the steps:

  • Extract the requiresFoundryMaxCompletionTokens function from shared-x9RbOMks.js and create a shared requiresMaxCompletionTokens(modelId) helper function.
  • Update onboard-custom-DY0XuRoF.js and onboard-iE_s6O7s.js to use the new requiresMaxCompletionTokens helper function to determine whether to use max_tokens or max_completion_tokens in probe calls.
  • Update any other Chat Completions request builders that hardcode max_tokens to use the requiresMaxCompletionTokens helper function.

Example code for the requiresMaxCompletionTokens helper function:

function requiresMaxCompletionTokens(modelId) {
  const normalized = normalizeModelName(modelId);
  if (!normalized) return false;
  return normalized.startsWith("gpt-5") || normalized.startsWith("o1") || 
         normalized.startsWith("o3") || normalized.startsWith("o4");
}

Example code for updating onboard-custom-DY0XuRoF.js:

// ...

const params = {
  // ...
  max_tokens: requiresMaxCompletionTokens(modelId) ? 'max_completion_tokens' : 'max_tokens',
  // ...
};

// ...

Verification

To verify that the fix worked, test the Discord channel session with the openai/gpt-5.4 model and ensure that the agent responds correctly without showing the ⚠️ Agent failed before reply error.

Extra Tips

  • Make sure to update all relevant code paths that use max_tokens to use the requiresMaxCompletionTokens helper function.
  • Test the fix with different models to ensure that it works correctly for all cases.
  • Consider adding logging or monitoring to detect and report any future issues with model compatibility.

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