[GH-ISSUE #409] [Issue]: [v1.5.7] OpenRouter Claude returns 400 on non-initial generations when reasoning effort #171

Closed
opened 2026-10-20 17:25:51 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @cha1latte on GitHub (May 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/409

Originally assigned to: @SpicyMarinara on GitHub.

Summary

After upgrading to v1.5.7 (commit 84498fd), Claude Opus 4.6 via OpenRouter returns OpenAI API error 400: Provider returned error on any non-initial generation when reasoning effort is set to low, medium, high, or maximum. Initial messages and regenerations of existing messages succeed. effort: none works at any verbosity. Worked correctly in v1.5.4.

Environment

  • Marinara Engine: v1.5.7 (84498fd)
  • Host OS: Windows
  • Clients tested: iOS Safari, macOS Firefox (over Tailscale), Firefox on host
  • Connection: OpenRouter → anthropic/claude-opus-4.6
  • Settings: Temp 1, MaxTokens 8192, MaxContext 128000, EnableThinking true, ShowThoughts true, Stream true

Steps to Reproduce

  1. Configure OpenRouter connection with anthropic/claude-opus-4.6.
  2. Enable thinking; set effort to low (or higher).
  3. Start a new roleplay scene.
  4. Send the first message → ✅ works.
  5. Send a follow-up message → ❌ 400: Provider returned error.
  6. Regenerate the failing message → ✅ works (because the prior assistant turn is stripped).
  7. Set effort: none → ✅ all generations work (no thinking).

Expected Behavior

Non-initial generations should succeed with reasoning enabled, matching v1.5.4 behavior.

Actual Behavior

OpenAI API error 400: Provider returned error

No further detail in server or client console.

Root Cause Analysis

The v1.5.7 changelog notes:

"OpenRouter Claude reasoning is requested with OpenRouter's unified reasoning payload again, restoring thinking capture for Sonnet/Opus reasoning models."

Per OpenRouter's reasoning-tokens documentation:

"When continuing a conversation, preserve the complete reasoning_details when passing messages back to the model so it can continue reasoning from where it left off."

"When providing reasoning_details blocks, the entire sequence of consecutive reasoning blocks must match the outputs generated by the model during the original request; you cannot rearrange or modify the sequence of these blocks."

This explains every observed symptom:

Symptom Cause
First message works No prior assistant turns in messages[] — no reasoning_details to preserve.
Regenerate works Last assistant turn is stripped before resending — no broken reasoning_details in payload.
New follow-up fails Prior assistant turn is included, but without round-tripped reasoning_details.
effort: none works Reasoning not requested → preservation rule doesn't apply.
verbosity doesn't matter Verbosity isn't part of the reasoning contract.

The likely location is packages/server/src/services/llm/providers/openai.provider.ts. The provider is sending reasoning: { effort } at the request level but not capturing reasoning_details from each assistant response and re-attaching them to historical assistant messages on subsequent turns.

Suggested Fix

  1. When parsing OpenRouter responses for reasoning models, capture the reasoning_details array from each assistant message and persist it alongside chat history.
  2. When serializing prior assistant turns into messages[] for a follow-up request, include the captured reasoning_details on each assistant message verbatim — same order, no modification.
  3. Only apply this when the request is using the unified reasoning payload (i.e., effort is set and the provider is OpenRouter for a Claude/OpenAI reasoning model).

Workaround

Set effort: none until fix is released. Generation works, just without thinking.

Regression Marker

Last known-good version: v1.5.4 (thinking with OpenRouter Opus generated successfully on follow-up turns).


Want me to also draft the PR description if/when there's a fix branch, or is the issue enough?

</html> </html>Here's a GitHub issue ready to paste:

Title: [v1.5.7] OpenRouter Claude returns 400 on non-initial generations when reasoning effort ≥ low


Summary

After upgrading to v1.5.7 (commit 84498fd), Claude Opus 4.6 via OpenRouter returns OpenAI API error 400: Provider returned error on any non-initial generation when reasoning effort is set to low, medium, high, or maximum. Initial messages and regenerations of existing messages succeed. effort: none works at any verbosity. Worked correctly in v1.5.4.

Environment

  • Marinara Engine: v1.5.7 (84498fd)
  • Host OS: Windows
  • Clients tested: iOS Safari, macOS Firefox (over Tailscale), Firefox on host
  • Connection: OpenRouter → anthropic/claude-opus-4.6
  • Settings: Temp 1, MaxTokens 8192, MaxContext 128000, EnableThinking true, ShowThoughts true, Stream true

Steps to Reproduce

  1. Configure OpenRouter connection with anthropic/claude-opus-4.6.
  2. Enable thinking; set effort to low (or higher).
  3. Start a new roleplay scene.
  4. Send the first message → ✅ works.
  5. Send a follow-up message → ❌ 400: Provider returned error.
  6. Regenerate the failing message → ✅ works (because the prior assistant turn is stripped).
  7. Set effort: none → ✅ all generations work (no thinking).

Expected Behavior

Non-initial generations should succeed with reasoning enabled, matching v1.5.4 behavior.

Actual Behavior

OpenAI API error 400: Provider returned error

No further detail in server or client console.

Root Cause Analysis

The v1.5.7 changelog notes:

"OpenRouter Claude reasoning is requested with OpenRouter's unified reasoning payload again, restoring thinking capture for Sonnet/Opus reasoning models."

Per [OpenRouter's reasoning-tokens documentation](https://openrouter.ai/docs/guides/best-practices/reasoning-tokens):

"When continuing a conversation, preserve the complete reasoning_details when passing messages back to the model so it can continue reasoning from where it left off."

"When providing reasoning_details blocks, the entire sequence of consecutive reasoning blocks must match the outputs generated by the model during the original request; you cannot rearrange or modify the sequence of these blocks."

This explains every observed symptom:

Symptom Cause
First message works No prior assistant turns in messages[] — no reasoning_details to preserve.
Regenerate works Last assistant turn is stripped before resending — no broken reasoning_details in payload.
New follow-up fails Prior assistant turn is included, but without round-tripped reasoning_details.
effort: none works Reasoning not requested → preservation rule doesn't apply.
verbosity doesn't matter Verbosity isn't part of the reasoning contract.

The likely location is packages/server/src/services/llm/providers/openai.provider.ts. The provider is sending reasoning: { effort } at the request level but not capturing reasoning_details from each assistant response and re-attaching them to historical assistant messages on subsequent turns.

Suggested Fix

  1. When parsing OpenRouter responses for reasoning models, capture the reasoning_details array from each assistant message and persist it alongside chat history.
  2. When serializing prior assistant turns into messages[] for a follow-up request, include the captured reasoning_details on each assistant message verbatim — same order, no modification.
  3. Only apply this when the request is using the unified reasoning payload (i.e., effort is set and the provider is OpenRouter for a Claude/OpenAI reasoning model).

Workaround

Set effort: none until fix is released. Generation works, just without thinking.

Regression Marker

Last known-good version: v1.5.4 (thinking with OpenRouter Opus generated successfully on follow-up turns).

Originally created by @cha1latte on GitHub (May 4, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/409 Originally assigned to: @SpicyMarinara on GitHub. <h3>Summary</h3> <p>After upgrading to v1.5.7 (commit <code>84498fd</code>), Claude Opus 4.6 via OpenRouter returns <code>OpenAI API error 400: Provider returned error</code> on any non-initial generation when reasoning <code>effort</code> is set to <code>low</code>, <code>medium</code>, <code>high</code>, or <code>maximum</code>. Initial messages and regenerations of existing messages succeed. <code>effort: none</code> works at any verbosity. Worked correctly in v1.5.4.</p> <h3>Environment</h3> <ul> <li><strong>Marinara Engine:</strong> v1.5.7 (<code>84498fd</code>)</li> <li><strong>Host OS:</strong> Windows</li> <li><strong>Clients tested:</strong> iOS Safari, macOS Firefox (over Tailscale), Firefox on host</li> <li><strong>Connection:</strong> OpenRouter → <code>anthropic/claude-opus-4.6</code></li> <li><strong>Settings:</strong> Temp 1, MaxTokens 8192, MaxContext 128000, EnableThinking true, ShowThoughts true, Stream true</li> </ul> <h3>Steps to Reproduce</h3> <ol> <li>Configure OpenRouter connection with <code>anthropic/claude-opus-4.6</code>.</li> <li>Enable thinking; set <code>effort</code> to <code>low</code> (or higher).</li> <li>Start a new roleplay scene.</li> <li>Send the first message → ✅ works.</li> <li>Send a follow-up message → ❌ <code>400: Provider returned error</code>.</li> <li>Regenerate the failing message → ✅ works (because the prior assistant turn is stripped).</li> <li>Set <code>effort: none</code> → ✅ all generations work (no thinking).</li> </ol> <h3>Expected Behavior</h3> <p>Non-initial generations should succeed with reasoning enabled, matching v1.5.4 behavior.</p> <h3>Actual Behavior</h3> <pre><code>OpenAI API error 400: Provider returned error </code></pre> <p>No further detail in server or client console.</p> <h3>Root Cause Analysis</h3> <p>The v1.5.7 changelog notes:</p> <blockquote> <p><em>"OpenRouter Claude reasoning is requested with OpenRouter's unified reasoning payload again, restoring thinking capture for Sonnet/Opus reasoning models."</em></p> </blockquote> <p>Per <a href="https://openrouter.ai/docs/guides/best-practices/reasoning-tokens">OpenRouter's reasoning-tokens documentation</a>:</p> <blockquote> <p><em>"When continuing a conversation, preserve the complete <code>reasoning_details</code> when passing messages back to the model so it can continue reasoning from where it left off."</em></p> <p><em>"When providing reasoning_details blocks, the entire sequence of consecutive reasoning blocks must match the outputs generated by the model during the original request; you cannot rearrange or modify the sequence of these blocks."</em></p> </blockquote> <p>This explains every observed symptom:</p> Symptom | Cause -- | -- First message works | No prior assistant turns in messages[] — no reasoning_details to preserve. Regenerate works | Last assistant turn is stripped before resending — no broken reasoning_details in payload. New follow-up fails | Prior assistant turn is included, but without round-tripped reasoning_details. effort: none works | Reasoning not requested → preservation rule doesn't apply. verbosity doesn't matter | Verbosity isn't part of the reasoning contract. <p>The likely location is <code>packages/server/src/services/llm/providers/openai.provider.ts</code>. The provider is sending <code>reasoning: { effort }</code> at the request level but not capturing <code>reasoning_details</code> from each assistant response and re-attaching them to historical assistant messages on subsequent turns.</p> <h3>Suggested Fix</h3> <ol> <li>When parsing OpenRouter responses for reasoning models, capture the <code>reasoning_details</code> array from each assistant message and persist it alongside chat history.</li> <li>When serializing prior assistant turns into <code>messages[]</code> for a follow-up request, include the captured <code>reasoning_details</code> on each assistant message verbatim — same order, no modification.</li> <li>Only apply this when the request is using the unified reasoning payload (i.e., <code>effort</code> is set and the provider is OpenRouter for a Claude/OpenAI reasoning model).</li> </ol> <h3>Workaround</h3> <p>Set <code>effort: none</code> until fix is released. Generation works, just without thinking.</p> <h3>Regression Marker</h3> <p>Last known-good version: <strong>v1.5.4</strong> (thinking with OpenRouter Opus generated successfully on follow-up turns).</p> <hr> <p>Want me to also draft the PR description if/when there's a fix branch, or is the issue enough?</p></body></html><!--EndFragment--> </body> </html>Here's a GitHub issue ready to paste: --- **Title:** `[v1.5.7] OpenRouter Claude returns 400 on non-initial generations when reasoning effort ≥ low` --- ### Summary After upgrading to v1.5.7 (commit `84498fd`), Claude Opus 4.6 via OpenRouter returns `OpenAI API error 400: Provider returned error` on any non-initial generation when reasoning `effort` is set to `low`, `medium`, `high`, or `maximum`. Initial messages and regenerations of existing messages succeed. `effort: none` works at any verbosity. Worked correctly in v1.5.4. ### Environment - **Marinara Engine:** v1.5.7 (`84498fd`) - **Host OS:** Windows - **Clients tested:** iOS Safari, macOS Firefox (over Tailscale), Firefox on host - **Connection:** OpenRouter → `anthropic/claude-opus-4.6` - **Settings:** Temp 1, MaxTokens 8192, MaxContext 128000, EnableThinking true, ShowThoughts true, Stream true ### Steps to Reproduce 1. Configure OpenRouter connection with `anthropic/claude-opus-4.6`. 2. Enable thinking; set `effort` to `low` (or higher). 3. Start a new roleplay scene. 4. Send the first message → ✅ works. 5. Send a follow-up message → ❌ `400: Provider returned error`. 6. Regenerate the failing message → ✅ works (because the prior assistant turn is stripped). 7. Set `effort: none` → ✅ all generations work (no thinking). ### Expected Behavior Non-initial generations should succeed with reasoning enabled, matching v1.5.4 behavior. ### Actual Behavior ``` OpenAI API error 400: Provider returned error ``` No further detail in server or client console. ### Root Cause Analysis The v1.5.7 changelog notes: > *"OpenRouter Claude reasoning is requested with OpenRouter's unified reasoning payload again, restoring thinking capture for Sonnet/Opus reasoning models."* Per [[OpenRouter's reasoning-tokens documentation](https://openrouter.ai/docs/guides/best-practices/reasoning-tokens)](https://openrouter.ai/docs/guides/best-practices/reasoning-tokens): > *"When continuing a conversation, preserve the complete `reasoning_details` when passing messages back to the model so it can continue reasoning from where it left off."* > > *"When providing reasoning_details blocks, the entire sequence of consecutive reasoning blocks must match the outputs generated by the model during the original request; you cannot rearrange or modify the sequence of these blocks."* This explains every observed symptom: | Symptom | Cause | |---|---| | First message works | No prior assistant turns in `messages[]` — no `reasoning_details` to preserve. | | Regenerate works | Last assistant turn is stripped before resending — no broken `reasoning_details` in payload. | | New follow-up fails | Prior assistant turn is included, but without round-tripped `reasoning_details`. | | `effort: none` works | Reasoning not requested → preservation rule doesn't apply. | | `verbosity` doesn't matter | Verbosity isn't part of the reasoning contract. | The likely location is `packages/server/src/services/llm/providers/openai.provider.ts`. The provider is sending `reasoning: { effort }` at the request level but not capturing `reasoning_details` from each assistant response and re-attaching them to historical assistant messages on subsequent turns. ### Suggested Fix 1. When parsing OpenRouter responses for reasoning models, capture the `reasoning_details` array from each assistant message and persist it alongside chat history. 2. When serializing prior assistant turns into `messages[]` for a follow-up request, include the captured `reasoning_details` on each assistant message verbatim — same order, no modification. 3. Only apply this when the request is using the unified reasoning payload (i.e., `effort` is set and the provider is OpenRouter for a Claude/OpenAI reasoning model). ### Workaround Set `effort: none` until fix is released. Generation works, just without thinking. ### Regression Marker Last known-good version: **v1.5.4** (thinking with OpenRouter Opus generated successfully on follow-up turns).
bsakaguchi 2026-10-20 17:25:51 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@AlbatrossAscot commented on GitHub (May 4, 2026):

Something lost in the LLM telephone: retrying a generation that was produced before the latest changes in 1.5.7 will work, even with thinking enabled, and it will think properly. That is, I can regenerate messages in RPs from yesterday with thinking enabled.

A generation from after the latest 1.5.7 changes, like one generated just now through the workaround of disabling thinking, will not regenerate with thinking enabled. It will produce the same 400.

<!-- gh-comment-id:4374200487 --> @AlbatrossAscot commented on GitHub (May 4, 2026): Something lost in the LLM telephone: retrying a generation that was produced *before* the latest changes in 1.5.7 will work, even with thinking enabled, and it will think properly. That is, I can regenerate messages in RPs from yesterday with thinking enabled. A generation from *after* the latest 1.5.7 changes, like one generated just now through the workaround of disabling thinking, will *not* regenerate with thinking enabled. It will produce the same 400.
Author
Owner

@Pinkmoth419 commented on GitHub (May 4, 2026):

Also having this issue, haven't found a workaround yet but will share if I do 🫶🏻

<!-- gh-comment-id:4374511509 --> @Pinkmoth419 commented on GitHub (May 4, 2026): Also having this issue, haven't found a workaround yet but will share if I do 🫶🏻
Author
Owner

@SpicyMarinara commented on GitHub (May 5, 2026):

Fix push soon.

<!-- gh-comment-id:4377639254 --> @SpicyMarinara commented on GitHub (May 5, 2026): Fix push soon.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#171
No description provided.