anomalyco / anomalyco/opencode
sap-ai-core: Claude models fail with 400 "does not support assistant message prefill"
@nexxeln is already working on this.
Since Aug 26, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Bug Report
OpenCode Version: 1.18.23
Provider: sap-ai-core
Model: sap-ai-core/anthropic--claude-4.6-sonnet (affects all sap-ai-core/anthropic--* models)
Description
When using any Anthropic/Claude model through the SAP AI Core provider, every response is followed by a 400 error:
400 - LLM Module: This model does not support assistant message prefill.
The conversation must end with a user message.
Steps to Reproduce
- Configure OpenCode with
sap-ai-coreprovider and anyanthropic--*model - Send any message (e.g. "Hi")
- Receive a response
- Observe 400 error immediately after
Root Cause
OpenCode appends a partial assistant message at the end of the conversation (assistant prefill) to steer the model's response. The SAP AI Core Orchestration API rejects this — it requires conversations to always end with a user message.
Relevant source file:
packages/opencode/src/provider/provider.ts — sap-ai-core custom loader
The fix requires stripping any trailing assistant message before sending to SAP AI Core, or disabling prefill specifically for this provider.
Expected Behavior
Messages to SAP AI Core Claude models should not include a trailing assistant message. The conversation should always end with a user message.
Workaround
None currently available via config. The only workaround is to not use Anthropic/Claude models through SAP AI Core.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.