mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8778] [MERGED] fix(server): stop streamed-output fallbacks, empty JSON replies and partial package completions #8800
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8800
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8778
Author: @SpicyMarinara
Created: 11/3/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/llm-streaming-fallbacks📝 Commits (2)
9a8d2c7fix(server): stop streamed-output fallbacks, empty JSON replies and partial package completions9b12148fix(server): let keepalive-only chatComplete callers keep their fallback📊 Changes
11 files changed (+144 additions, -10 deletions)
View changed files
📝
packages/server/src/routes/game.routes.ts(+6 -0)📝
packages/server/src/services/agents/agent-progress.ts(+2 -0)📝
packages/server/src/services/capability-packages/capability-language-model.service.ts(+5 -0)📝
packages/server/src/services/llm/connection-fallback-provider.ts(+18 -3)📝
packages/server/src/services/llm/providers/openai.provider.ts(+11 -6)📝
packages/shared/src/types/generation-integration.ts(+5 -0)📝
scripts/regressions/agent-progress.regression.ts(+14 -0)📝
scripts/regressions/game-generation-parameters.regression.ts(+8 -0)📝
scripts/regressions/llm-inactivity-timeout.regression.ts(+14 -1)📝
scripts/regressions/openai-json-stream-response.regression.ts(+20 -0)📝
scripts/regressions/provider-compat.regression.ts(+41 -0)📄 Description
Linked issue
Closes #8777
Why this change
A release-prep audit found three LLM streaming failure paths. Two independent verifiers checked each one.
Some callers pass onToken only to keep a watchdog or progress display alive (Game setup, session conclusion, campaign progression, Lorebook Keeper, agent progress). Those still use the fallback, because nothing they streamed reached the user.
No issue is linked: these came from the release-prep audit. Per CONTRIBUTING, an issue should be opened before this PR is submitted.
What changed
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Agent-run checks (for reference; each regression was shown to fail without its fix):
node ./scripts/pnpm-runner.mjs build:shared: succeedednode ./scripts/run-regressions.mjs --filter scripts/regressions/provider-compat.regression (with fix / connection-fallback-provider.ts reverted to round 1): PASSED with fix; FAILED without it at the new keepalive case (provider-compat.regression.ts:2760 rejected with 'stream interrupted after callback output')node ./scripts/run-regressions.mjs --filter scripts/regressions/agent-progress.regression (with fix / agent-progress.ts reverted): PASSED with fix; FAILED without it at :24 (onTokenKeepaliveOnly actual undefined, expected false)node ./scripts/run-regressions.mjs --filter scripts/regressions/game-generation-parameters.regression (with fix / game.routes.ts reverted): PASSED with fix; FAILED without it at :94 (actual undefined, expected true)node ./scripts/run-regressions.mjs --filter scripts/regressions/<name>.regression, run one at a time for 27 regressions: provider-compat, openai-json-stream-res: all 27 passed (each reported 1/1 passed)cd packages/server && node ../../scripts/pnpm-runner.mjs lint (tsc -b ../shared && tsc --noEmit && tsc -p ../../scripts/regressions/tsconfig.character-activity.: exit 0cd packages/shared && node ../../scripts/pnpm-runner.mjs lint (generate-feature-registries + tsc --noEmit): exit 0; no tracked files changednode_modules/.bin/prettier --write, then --check, on every file changed on the branch: All matched files use Prettier code styleeslint on changed files: Not applicable: ESLint is configured only for packages/client, and no client files changed. The server and shared lint scripts are tsc, which passed above.Independent adversarial review: changes, 2 issue(s), all addressed in a fix-up pass.
Known limits and risks:
Default for unmarked callers. A caller that passes onToken and does not set onTokenKeepaliveOnly now gets the primary's error after a mid-stream failure, not the fallback. That is right for callers that show or keep the text. A future keepalive-only caller that forgets the flag would lose its fallback (an error, never garbled output). I chose this default (reviewer option 2) over an opt-in flag because the keepalive set is small and known: five Game call sites plus the agent progress hook. The callers that show text are spread out (tool rounds, raw route, dry run, agent executor, Professor Mari, capability integration packages). An opt-in flag would quietly go back to appending the fallback wherever someone forgot it.
Agents and packages. Streamed agent-executor calls with an agents fallback configured now fail on a mid-stream primary error instead of parsing mixed text. Making them use the fallback would mean changing agent-executor to prefer result.content over the text it accumulated. That is outside this fix. Capability packages that use the integration host's withFallback with a keepalive-only onToken would need to set the new optional ChatOptions.onTokenKeepaliveOnly. No Capability API version was bumped: version files are off limits for this task, and the field is optional.
Package host message. The package-host change rejects any result with finishReason 'error', including an upstream finish_reason 'error' that arrived with complete-looking text. The package gets a generic message, and the provider's own error is only logged (marked with a ponytail: comment). A mid-stream failure on a package call is also not retried by the rate-limit wrapper, because the host rejects after the provider returns.
Reviewer notes I did not act on:
afe9ddbd42, and no real endpoint doing this was found.Nothing was pushed and no PR was opened.
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.