fix(openrouter): strip Anthropic reasoning prefill

This commit is contained in:
Peter Steinberger
2026-05-02 06:46:37 +01:00
parent dc72a2aa42
commit 24d5649284
7 changed files with 235 additions and 9 deletions

View File

@@ -159,6 +159,13 @@ does **not** inject those OpenRouter-specific headers or Anthropic cache markers
better prompt-cache reuse on system/developer prompt blocks.
</Accordion>
<Accordion title="Anthropic reasoning prefill">
On verified OpenRouter routes, Anthropic model refs with reasoning enabled
drop trailing assistant prefill turns before the request reaches OpenRouter,
matching Anthropic's requirement that reasoning conversations end with a user
turn.
</Accordion>
<Accordion title="Thinking / reasoning injection">
On supported non-`auto` routes, OpenClaw maps the selected thinking level to
OpenRouter proxy reasoning payloads. Unsupported model hints and

View File

@@ -177,6 +177,12 @@ inter-session user turns that only have provenance metadata.
- Thought signature cleanup: strip non-base64 `thought_signature` values (keep base64).
**OpenRouter Anthropic**
- Trailing assistant prefill turns are stripped from verified OpenRouter
OpenAI-compatible Anthropic model payloads when reasoning is enabled, matching
direct Anthropic and Cloudflare Anthropic replay behavior.
**Everything else**
- Image sanitization only.