openclaw - ✅(Solved) Fix [Bug]: 2026.4.25 Breaks Cloudflare AI Gateway [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

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#72905Fetched 2026-04-28 06:30:31
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×2closed ×1commented ×1cross-referenced ×1

Hello,

I upgraded to 2026.4.25 and using Anthropic models does not work anymore with the Cloudflare AI Gateway. Here's what shows up in the openclaw logs:

16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message." 16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=session:agent:main:main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message."

16:05:30+00:00 error Embedded agent failed before reply: All models failed (3): cloudflare-ai-gateway/claude-sonnet-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZVaP4wAn5UFoetNSKv"} (format) | cloudflare-ai-gateway/claude-opus-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZW6bG1kZzARtZry7Av"} (format) | cloudflare-ai-gateway/claude-haiku-4-5: cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response (format) | cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response

I downgraded back to 2026.4.24 and everything worked again as expected.

Error Message

16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message." 16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=session:agent:main:main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message."

16:05:30+00:00 error Embedded agent failed before reply: All models failed (3): cloudflare-ai-gateway/claude-sonnet-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZVaP4wAn5UFoetNSKv"} (format) | cloudflare-ai-gateway/claude-opus-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZW6bG1kZzARtZry7Av"} (format) | cloudflare-ai-gateway/claude-haiku-4-5: cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response (format) | cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response

Root Cause

Hello,

I upgraded to 2026.4.25 and using Anthropic models does not work anymore with the Cloudflare AI Gateway. Here's what shows up in the openclaw logs:

16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message." 16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=session:agent:main:main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message."

16:05:30+00:00 error Embedded agent failed before reply: All models failed (3): cloudflare-ai-gateway/claude-sonnet-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZVaP4wAn5UFoetNSKv"} (format) | cloudflare-ai-gateway/claude-opus-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZW6bG1kZzARtZry7Av"} (format) | cloudflare-ai-gateway/claude-haiku-4-5: cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response (format) | cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response

I downgraded back to 2026.4.24 and everything worked again as expected.

Fix Action

Fix / Workaround

  1. Upgrade to 2026.4.25.
  2. Attempt to chat with agent.
  3. Receive error.

PR fix notes

PR #73005: Fix: Issue 72905 cloudflare ai gateway prefill

Description (problem / solution / changelog)

Summary

Describe the problem and fix in 2–5 bullets:

If this PR fixes a plugin beta-release blocker, title it fix(<plugin-id>): beta blocker - <summary> and link the matching Beta blocker: <plugin-name> - <summary> issue labeled beta-blocker. Contributors cannot label PRs, so the title is the PR-side signal for maintainers and automation.

  • Problem: Cloudflare AI Gateway requests using Anthropic Messages could fail when extended thinking was enabled because OpenClaw preserved trailing assistant prefill turns that Anthropic rejects for thinking requests.
  • Why it matters: Claude requests routed through Cloudflare AI Gateway could fail even though the native Anthropic provider already handled this payload rule.
  • What changed: Added Cloudflare AI Gateway stream wrapping for Anthropic-style thinking payloads, extracted the shared prefill-stripping helper into the plugin SDK, added focused tests, updated changelog, and refreshed the SDK API baseline.
  • What did NOT change (scope boundary): No provider auth, model catalog, gateway routing, non-Anthropic payload behavior, or Cloudflare AI Gateway network behavior changed.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #72905
  • Related #
  • This PR fixes a bug or regression

Root Cause (if applicable)

For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write N/A. If the cause is unclear, write Unknown.

  • Root cause: The native Anthropic provider stripped trailing assistant prefill messages when thinking was enabled, but the Cloudflare AI Gateway provider did not apply the same Anthropic payload normalization before forwarding the request.
  • Missing detection / guardrail: Cloudflare AI Gateway had discovery/registration coverage, but no stream-wrapper coverage for Anthropic thinking payload validation.
  • Contributing context (if known): Anthropic rejects thinking-enabled Messages requests when the final assistant turn is text prefill rather than a valid user/tool-use conversation boundary.

Regression Test Plan (if applicable)

For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write N/A.

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
    • Target test or file: extensions/cloudflare-ai-gateway/stream-wrappers.test.ts, extensions/cloudflare-ai-gateway/index.test.ts, src/plugin-sdk/provider-stream-shared.test.ts
    • Scenario the test should lock in: Thinking-enabled Anthropic Messages payloads routed through Cloudflare AI Gateway strip trailing assistant text prefill turns while preserving assistant tool-use turns and non-thinking payloads.
    • Why this is the smallest reliable guardrail: The bug is payload shaping before provider streaming, so unit and provider-registration seam tests cover the failing behavior without needing live Cloudflare or Anthropic credentials.
    • Existing test that already covers this (if any): Native Anthropic wrapper behavior had related coverage, but Cloudflare AI Gateway did not.
    • If no new test is added, why not: N/A

User-visible / Behavior Changes

Cloudflare AI Gateway users sending Claude requests with thinking enabled should no longer hit Anthropic conversation-ending validation failures caused by trailing assistant text prefill turns.

Diagram (if applicable)

For UI changes or non-trivial logic flows, include a small ASCII diagram reviewers can scan quickly. Otherwise write N/A.

  Before:
  OpenClaw Claude request with thinking -> Cloudflare AI Gateway -> Anthropic rejects trailing assistant prefill

  After:
  OpenClaw Claude request with thinking -> strip trailing assistant text prefill -> Cloudflare AI Gateway -> Anthropic-compatible payload

Security Impact (required)

  • New permissions/capabilities? (Yes/No): No
  • Secrets/tokens handling changed? (Yes/No): No
  • New/changed network calls? (Yes/No): No
  • Command/tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: Node 22 / pnpm
  • Model/provider: Anthropic Messages via Cloudflare AI Gateway
  • Integration/channel (if any): Cloudflare AI Gateway plugin
  • Relevant config (redacted): Thinking-enabled Anthropic Messages payload with trailing assistant text prefill

Steps

  1. Configure a Claude request through Cloudflare AI Gateway with thinking enabled.
  2. Include one or more trailing assistant text prefill messages in the Anthropic Messages payload.
  3. Send the request through the Cloudflare AI Gateway provider stream wrapper.

Expected

  • The trailing assistant text prefill turns are removed before the request is sent.
  • Assistant tool-use turns are preserved.
  • Payloads without thinking enabled are unchanged.

Actual

  • Before this fix, Cloudflare AI Gateway forwarded the trailing assistant text prefill turns and Anthropic rejected the request.
  • After this fix, the Cloudflare AI Gateway wrapper applies the same Anthropic thinking prefill normalization as the native Anthropic provider.

Evidence

Attach at least one:

  • Failing test/log before + passing after

  • Trace/log snippets

  • Screenshot/recording

  • Perf numbers (if relevant)

    pnpm test src/plugin-sdk/provider-stream-shared.test.ts extensions/anthropic/stream-wrappers.test.ts extensions/cloudflare-ai-gateway pnpm check:changed pnpm build pnpm plugin-sdk:api:check git diff --check codex review --base origin/main

    Final Codex review result: no correctness issues found.

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: Cloudflare AI Gateway strips trailing assistant text prefill when thinking is enabled; multiple trailing assistant prefill turns are stripped; assistant tool-use turns are preserved; non-thinking payloads are unchanged; plugin registration wires the wrapper.
  • Edge cases checked: payload without a messages array, OpenAI-shaped tool-use fields, Anthropic content-block tool-use fields, shared helper compatibility with the native Anthropic provider.
  • What you did not verify: Live Cloudflare AI Gateway or Anthropic network request with real credentials.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No): Yes
  • Config/env changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk: Shared helper behavior could accidentally diverge from the native Anthropic provider’s previous local implementation.
    • Mitigation: Preserved the native Anthropic wrapper callback behavior and added shared-helper tests covering Anthropic and OpenAI-shaped tool-use turns, plus reran Anthropic wrapper tests.

Built with Codex

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • extensions/anthropic/stream-wrappers.ts (modified, +11/-56)
  • extensions/cloudflare-ai-gateway/index.test.ts (added, +46/-0)
  • extensions/cloudflare-ai-gateway/index.ts (modified, +3/-0)
  • extensions/cloudflare-ai-gateway/stream-wrappers.test.ts (added, +110/-0)
  • extensions/cloudflare-ai-gateway/stream-wrappers.ts (added, +15/-0)
  • src/plugin-sdk/provider-stream-shared.test.ts (modified, +55/-0)
  • src/plugin-sdk/provider-stream-shared.ts (modified, +62/-0)

Code Example

16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message."
16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=session:agent:main:main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message."

16:05:30+00:00 error Embedded agent failed before reply: All models failed (3): cloudflare-ai-gateway/claude-sonnet-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZVaP4wAn5UFoetNSKv"} (format) | cloudflare-ai-gateway/claude-opus-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZW6bG1kZzARtZry7Av"} (format) | cloudflare-ai-gateway/claude-haiku-4-5: cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response (format) | cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Hello,

I upgraded to 2026.4.25 and using Anthropic models does not work anymore with the Cloudflare AI Gateway. Here's what shows up in the openclaw logs:

16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message." 16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=session:agent:main:main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message."

16:05:30+00:00 error Embedded agent failed before reply: All models failed (3): cloudflare-ai-gateway/claude-sonnet-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZVaP4wAn5UFoetNSKv"} (format) | cloudflare-ai-gateway/claude-opus-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZW6bG1kZzARtZry7Av"} (format) | cloudflare-ai-gateway/claude-haiku-4-5: cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response (format) | cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response

I downgraded back to 2026.4.24 and everything worked again as expected.

Steps to reproduce

  1. Upgrade to 2026.4.25.
  2. Attempt to chat with agent.
  3. Receive error.

Expected behavior

Models should respond in chat normally.

Actual behavior

Model does not respond after upgrade.

OpenClaw version

2026.4.25

Operating system

Ubuntu 24.04 LTS

Install method

one liner shells script

Model

Any Claude model

Provider / routing chain

cloudflare-ai-gateway -> Anthropic

Additional provider/model setup details

No response

Logs, screenshots, and evidence

16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message."
16:01:54+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=session:agent:main:main durationMs=6725 error="FailoverError: LLM request rejected: This model does not support assistant message prefill. The conversation must end with a user message."

16:05:30+00:00 error Embedded agent failed before reply: All models failed (3): cloudflare-ai-gateway/claude-sonnet-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZVaP4wAn5UFoetNSKv"} (format) | cloudflare-ai-gateway/claude-opus-4-6: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This model does not support assistant message prefill. The conversation must end with a user message."},"request_id":"req_011CaUZW6bG1kZzARtZry7Av"} (format) | cloudflare-ai-gateway/claude-haiku-4-5: cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response (format) | cloudflare-ai-gateway/claude-haiku-4-5 ended with an incomplete terminal response

Impact and severity

High impact as the models are completely unusable after the upgrade.

Additional information

No response

extent analysis

TL;DR

Downgrade to version 2026.4.24 to resolve the issue with Anthropic models not working with the Cloudflare AI Gateway.

Guidance

  • The error messages indicate that the models do not support assistant message prefill and the conversation must end with a user message, suggesting a compatibility issue with the upgraded version.
  • Verify that the issue is resolved by downgrading to version 2026.4.24 and attempting to chat with the agent again.
  • If downgrading is not feasible, consider reaching out to the Cloudflare AI Gateway support team to report the issue and request assistance with configuring the models to work with the upgraded version.
  • Review the OpenClaw logs to ensure that there are no other errors or warnings that may be contributing to the issue.

Example

No code snippet is provided as the issue appears to be related to a version compatibility problem rather than a code-specific issue.

Notes

The issue may be specific to the Cloudflare AI Gateway and Anthropic models, and may not affect other models or providers. Further investigation may be necessary to determine the root cause of the issue.

Recommendation

Downgrade to version 2026.4.24, as it has been confirmed to work as expected. This will allow you to continue using the Anthropic models with the Cloudflare AI Gateway until a fix is available for the upgraded version.

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…

FAQ

Expected behavior

Models should respond in chat normally.

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 - ✅(Solved) Fix [Bug]: 2026.4.25 Breaks Cloudflare AI Gateway [1 pull requests, 1 comments, 2 participants]