You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Step-cap assistant message causes 400 on Claude models with thinking enabled #32548
When an agent hits its step cap, the prompt loop appends an assistant-role message containing the "MAXIMUM STEPS REACHED" text. This makes the final message in the request an assistant turn, which Anthropic treats as a response prefill. Claude models with thinking enabled reject it:
400 This model does not support assistant message prefill. The conversation must end with a user message.
The injection is at packages/opencode/src/session/prompt.ts, around line 1343.
In opencode.json, set a low step cap on any agent:
{
"agent": {
"build": {
"steps": 2
}
}
}
Start a session using a Claude model with thinking enabled (Opus 4.6+)
Give it a task that requires tool calls, e.g. "read package.json, then search in the web multiple times for the dependencies if we can trust them and summarize it"
The agent hits the cap after 2 steps, OpenCode appends the MAXIMUM STEPS REACHED assistant message, and the next request returns:
400 This model does not support assistant message prefill. The conversation must end with a user message.
Session ID: ses_12fe4e903ffeyCq14Em7Xyshcb
Created: 6/16/2026, 8:04:56 PM
User:
read package.json search every dependency online and summarize it
Assistant (Build, Claude Opus 4.6, 5.8s):
Thinking: The user wants me to read the package.json file in the current project directory and then research each dependency online to summarize what each one does. Let me start by reading the package.json file.
Tool: memorysearch
Input: { "query": "package.json dependencies project stack", "collection": "all" }
Output: Searched in opencode_memory and opencode_plans, 61 + 3 hits.
Tool: read
Input: { "filePath": "/Users/kevinfaveri/Projects/KevinProfile/package.json" }
Output: package.json with 14 dependencies and 8 devDependencies (Next.js 16.2.6, React 19.2.4, AI SDK, Tailwind v4, etc.)
Assistant (Build, Claude Opus 4.6, 0.6s):
400 This model does not support assistant message prefill. The conversation must end with a user message.
The way I'm working around this at the fusion tool and locally is by setting a max steps per agent (built in and the ones from plugin) to a virtually very high number so its never hit, lol. Seems to address most of my frustrations @nexxeln
However having to use all those deep configs can be very non user friendly hence the issue and PR @nexxeln
Hit the same root cause from a different angle. Our setup uses Qwen3.6-35B-A3B via LiteLLM, no Claude/thinking involved — but the trailing assistant prefill still kills the response. The model just echoes the prefill verbatim (one stop token, completion_tokens=1) and the user sees the "CRITICAL - MAXIMUM STEPS REACHED..." block as if it came from the model. Confirmed end-to-end by replaying the captured request directly against the LLM:
role: user → 270 tokens, clean summary, finish_reason: stop
So the issue isn't specific to Claude/thinking — that's just the loudest symptom. Any provider that honors the assistant prefill convention has the same broken UX.
Opened #34276 with a two-line fix: change assistant to user in both prompt loops (V1 prompt.ts, V2 runner/llm.ts). Same approach as the earlier #16883, which was auto-closed by the template bot in March.
#32546 takes a different route (config flag to suppress the cap message). That works as an escape hatch, but the message itself is useful — the model genuinely should know it hit the cap so it can summarize instead of being silently truncated. The role fix preserves the message and makes the model actually respond to it.
Still reproduces on 1.18.3, and the injection line is unchanged on dev. Hit it twice, each at exactly the agent's configured step ceiling, with all prior steps succeeding:
#34276 (send as user role instead of assistant prefill) is the right fix — the wrap-up message is useful, the model just needs to be allowed to answer it.
Activity
github-actions commentedon Jun 16, 2026
This issue might be a duplicate of existing issues. Please check:
MAX_STEPSassistant-role injection insession/prompt.tscausing 400 errors on models that reject assistant prefill when thinking is enabled. That issue also documents the empty-trailing-assistant case and proposes fixes.This model does not support assistant message prefill) reported across multiple Claude models and providers, with 70+ comments and an active assignee.Please review those issues to see if your report is already tracked there before continuing separately.
kevinfaveri commentedon Jun 16, 2026
The way I'm working around this at the fusion tool and locally is by setting a max steps per agent (built in and the ones from plugin) to a virtually very high number so its never hit, lol. Seems to address most of my frustrations @nexxeln
However having to use all those deep configs can be very non user friendly hence the issue and PR @nexxeln
Anooshiravan commentedon Jun 28, 2026
Hit the same root cause from a different angle. Our setup uses Qwen3.6-35B-A3B via LiteLLM, no Claude/thinking involved — but the trailing assistant prefill still kills the response. The model just echoes the prefill verbatim (one stop token, completion_tokens=1) and the user sees the "CRITICAL - MAXIMUM STEPS REACHED..." block as if it came from the model. Confirmed end-to-end by replaying the captured request directly against the LLM:
So the issue isn't specific to Claude/thinking — that's just the loudest symptom. Any provider that honors the assistant prefill convention has the same broken UX.
Opened #34276 with a two-line fix: change
assistanttouserin both prompt loops (V1 prompt.ts, V2 runner/llm.ts). Same approach as the earlier #16883, which was auto-closed by the template bot in March.#32546 takes a different route (config flag to suppress the cap message). That works as an escape hatch, but the message itself is useful — the model genuinely should know it hit the cap so it can summarize instead of being silently truncated. The role fix preserves the message and makes the model actually respond to it.
fernanDOTdo commentedon Jul 18, 2026
Still reproduces on 1.18.3, and the injection line is unchanged on dev. Hit it twice, each at exactly the agent's configured step ceiling, with all prior steps succeeding:
steps: 40, thinking variant (max) → 400 on step 40steps: 200, thinking variant (xhigh) → 400 on step 200#34276 (send as
userrole instead of assistant prefill) is the right fix — the wrap-up message is useful, the model just needs to be allowed to answer it.AdelinoGP commentedon Aug 8, 2026
Is this still not fixed? Even on V2 I am still getting this issue, I think #24505 might be a good way of fixing it, maybe as an option at least
github-actions commentedon Oct 8, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
fix(opencode): drop the reviewer step cap that Claude rejects as prefill