[PR #8389] [MERGED] fix: reasoning effort on custom endpoints, stuck "Generating" turns, rate-limit clock jumps #8570

Closed
opened 2026-11-07 16:45:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8389
Author: @kolacheee
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @kolacheee

Base: staging ← Head: fix/custom-gateway-generation


📝 Commits (8)

  • b267d70 fix(llm): send reasoning effort to reasoning models on custom endpoints
  • 4d1de4f fix(server): run rate-limit windows on a monotonic clock
  • 90fc24c fix(generate): stop interrupted or failed turns from hanging on "Generating"
  • 4677bd2 Merge branch 'staging' into fix/custom-gateway-generation
  • 8842ea0 fix: Retry falls back when nothing is sent; gateway effort refusals remembered
  • 722dd0b fix(generate): time the stopped-run release wait on the monotonic clock
  • 195c859 Merge remote-tracking branch 'origin/staging' into fix/custom-gateway-generation
  • db7d1a5 fix: one resend per Retry; refused-effort record on the monotonic clock

📊 Changes

11 files changed (+583 additions, -7 deletions)

View changed files

📝 packages/client/src/components/game/GameInput.tsx (+29 -1)
📝 packages/client/src/components/game/GameSurface.tsx (+24 -1)
📝 packages/client/src/hooks/use-generate.ts (+83 -3)
📝 packages/client/src/localization/locales/en.json (+1 -0)
📝 packages/server/src/middleware/rate-limit.ts (+8 -2)
📝 packages/server/src/routes/generate.routes.ts (+17 -0)
📝 packages/server/src/routes/generate/sse.ts (+9 -0)
📝 packages/server/src/services/llm/providers/openai.provider.ts (+105 -0)
➕ scripts/regressions/custom-gateway-reasoning-effort.regression.ts (+137 -0)
➕ scripts/regressions/generate-interrupted-retry.regression.ts (+115 -0)
➕ scripts/regressions/rate-limit-clock-jump.regression.ts (+55 -0)

📄 Description

Linked issue

Closes #8387

Why this change

  • On a custom OpenAI-compatible connection (LiteLLM, new-api, one-api), Claude, Gemini, DeepSeek, Qwen and similar reasoning models ran without the reasoning effort the user picked.
  • A turn could stay on "Generating..." with no way out: a turn sent right after Stop was refused with a 409 and lost, a run aborted elsewhere ended its stream with no done or error event, and a game turn whose background recovery left no Game Master message showed nothing.
  • When the system clock moved back (an NTP correction, a resumed VM), the rate limiter counted every bucket down to a reset hours away, so every client got 429.

What changed

  • Reasoning effort: custom endpoints now forward reasoning_effort for recognized reasoning model families, capping xhigh/max at high outside the OpenAI family. If the gateway refuses the parameter with a 400, the request is retried once without it. An effort set through Custom Parameters is left alone.
  • Stuck turns:
    • The server waits briefly for a stopped run to release the chat instead of answering 409.
    • A run aborted while its stream is open now sends an error event.
    • When the stream goes quiet for a minute, the client checks /generate/status and either reads back what was saved or shows the error with Retry.
    • A game turn with no GM message after recovery shows an error with Retry.
    • In game mode, Retry resends a typed turn the server never saved.
  • Rate limits: windows run on performance.now(); RateLimit-Reset is still reported against the wall clock.

Validation

  • New regressions pass: custom-gateway-reasoning-effort, generate-interrupted-retry, rate-limit-clock-jump
  • pnpm check passes locally (on the private branch these fixes came from)
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Played Game Mode through a custom OpenAI-compatible gateway with Gemini and DeepSeek models:

  • Checked that the chosen reasoning effort reaches the request.
  • Pressed Stop and sent a new turn right away, which was accepted.
  • Interrupted a run mid-stream and got Retry instead of an endless "Generating...".

Docs and release impact

No docs change. Release note: reasoning effort now applies to reasoning models on custom endpoints, interrupted turns no longer hang on "Generating", and rate limiting survives system clock changes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8389 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `fix/custom-gateway-generation` --- ### 📝 Commits (8) - [`b267d70`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b267d70b4d8265de3ab04bfaef1dc6ce8691fe1f) fix(llm): send reasoning effort to reasoning models on custom endpoints - [`4d1de4f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4d1de4f58161e3403e5332f928b51d0e85b1ba75) fix(server): run rate-limit windows on a monotonic clock - [`90fc24c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/90fc24c3cbbb5fb3ea5d04b580b6b59e551375e7) fix(generate): stop interrupted or failed turns from hanging on "Generating" - [`4677bd2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4677bd213b051db75ec6d288e10fd7cd75b2fbb2) Merge branch 'staging' into fix/custom-gateway-generation - [`8842ea0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8842ea0cbed04041571a8cab8cc807d28c69c8c3) fix: Retry falls back when nothing is sent; gateway effort refusals remembered - [`722dd0b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/722dd0b66a4aedecb3b80a035198b93068b7629e) fix(generate): time the stopped-run release wait on the monotonic clock - [`195c859`](https://github.com/Pasta-Devs/Marinara-Engine/commit/195c85952c112093fe75977f5530a3ec6f2d9967) Merge remote-tracking branch 'origin/staging' into fix/custom-gateway-generation - [`db7d1a5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/db7d1a5505ab3c28f1913490da8f99b233f9c0ab) fix: one resend per Retry; refused-effort record on the monotonic clock ### 📊 Changes **11 files changed** (+583 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/game/GameInput.tsx` (+29 -1) 📝 `packages/client/src/components/game/GameSurface.tsx` (+24 -1) 📝 `packages/client/src/hooks/use-generate.ts` (+83 -3) 📝 `packages/client/src/localization/locales/en.json` (+1 -0) 📝 `packages/server/src/middleware/rate-limit.ts` (+8 -2) 📝 `packages/server/src/routes/generate.routes.ts` (+17 -0) 📝 `packages/server/src/routes/generate/sse.ts` (+9 -0) 📝 `packages/server/src/services/llm/providers/openai.provider.ts` (+105 -0) ➕ `scripts/regressions/custom-gateway-reasoning-effort.regression.ts` (+137 -0) ➕ `scripts/regressions/generate-interrupted-retry.regression.ts` (+115 -0) ➕ `scripts/regressions/rate-limit-clock-jump.regression.ts` (+55 -0) </details> ### 📄 Description ## Linked issue Closes #8387 ## Why this change - On a custom OpenAI-compatible connection (LiteLLM, new-api, one-api), Claude, Gemini, DeepSeek, Qwen and similar reasoning models ran without the reasoning effort the user picked. - A turn could stay on "Generating..." with no way out: a turn sent right after Stop was refused with a 409 and lost, a run aborted elsewhere ended its stream with no done or error event, and a game turn whose background recovery left no Game Master message showed nothing. - When the system clock moved back (an NTP correction, a resumed VM), the rate limiter counted every bucket down to a reset hours away, so every client got 429. ## What changed - **Reasoning effort:** custom endpoints now forward `reasoning_effort` for recognized reasoning model families, capping xhigh/max at high outside the OpenAI family. If the gateway refuses the parameter with a 400, the request is retried once without it. An effort set through Custom Parameters is left alone. - **Stuck turns:** - The server waits briefly for a stopped run to release the chat instead of answering 409. - A run aborted while its stream is open now sends an error event. - When the stream goes quiet for a minute, the client checks `/generate/status` and either reads back what was saved or shows the error with Retry. - A game turn with no GM message after recovery shows an error with Retry. - In game mode, Retry resends a typed turn the server never saved. - **Rate limits:** windows run on `performance.now()`; `RateLimit-Reset` is still reported against the wall clock. ## Validation - [x] New regressions pass: `custom-gateway-reasoning-effort`, `generate-interrupted-retry`, `rate-limit-clock-jump` - [x] `pnpm check` passes locally (on the private branch these fixes came from) - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Played Game Mode through a custom OpenAI-compatible gateway with Gemini and DeepSeek models: - Checked that the chosen reasoning effort reaches the request. - Pressed Stop and sent a new turn right away, which was accepted. - Interrupted a run mid-stream and got Retry instead of an endless "Generating...". ## Docs and release impact No docs change. Release note: reasoning effort now applies to reasoning models on custom endpoints, interrupted turns no longer hang on "Generating", and rate limiting survives system clock changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:45:40 +07:00
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#8570
No description provided.