[GH-ISSUE #1257] [Issue]: LLM stream cancel can silently miss the original remote runtime target #615

Closed
opened 2026-10-20 17:30:47 +07:00 by bsakaguchi · 0 comments
Owner

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

## Summary

LLM stream cancellation can miss the original remote runtime target if the Remote Runtime URL changes while a stream is active. Cancel failures are also swallowed, which makes failed or misrouted cancellation hard to diagnose.

Expected behavior

A stream cancel request should target the same runtime that started the stream. If the cancel request fails, the app should keep cancellation best-effort but emit enough sanitized debug information to diagnose the failed cancel path.

Actual behavior

The shared API stream path checks that a remote runtime target exists, then the remote stream request resolves the target from the current UI store. On abort, cancelRemoteLlmStream resolves the remote runtime target again from the current UI store. If the setting changed between stream start and abort, cancel can be sent to a different runtime. Local and remote cancel failures were intentionally swallowed, so failures were not visible during debugging.

Steps to reproduce

  1. Configure Remote Runtime URL to server A.
  2. Start an LLM streaming request through the shared API remote runtime path.
  3. Change Remote Runtime URL to server B while the stream is still active.
  4. Abort/cancel the active stream.
  5. Observe that the cancel path can target server B instead of server A, leaving the original server A stream uncancelled. If the cancel request fails, the failure is not surfaced in logs.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: observed in origin/refactor shared API cancellation path before the fix branch
  • Run mode: remote runtime
  • OS + version: not OS-specific from code inspection
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not relevant
  • Remote Runtime URL configured? yes
  • Provider, model, or integration, if relevant: LLM streaming path; provider/model agnostic

Logs, screenshots, or video

No user log attached. Code path evidence is in src/shared/api/llm-api.ts and src/shared/api/remote-runtime.ts.

Regression notes

Unknown. This appears to be an existing edge case in the current refactor branch cancellation flow.

Additional context

A fix should capture the remote runtime target once at stream start, use that same target for both streaming and cancellation, and preserve best-effort cancellation while logging sanitized cancel failures.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (May 26, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1257 ## Summary LLM stream cancellation can miss the original remote runtime target if the Remote Runtime URL changes while a stream is active. Cancel failures are also swallowed, which makes failed or misrouted cancellation hard to diagnose. ## Expected behavior A stream cancel request should target the same runtime that started the stream. If the cancel request fails, the app should keep cancellation best-effort but emit enough sanitized debug information to diagnose the failed cancel path. ## Actual behavior The shared API stream path checks that a remote runtime target exists, then the remote stream request resolves the target from the current UI store. On abort, `cancelRemoteLlmStream` resolves the remote runtime target again from the current UI store. If the setting changed between stream start and abort, cancel can be sent to a different runtime. Local and remote cancel failures were intentionally swallowed, so failures were not visible during debugging. ## Steps to reproduce 1. Configure Remote Runtime URL to server A. 2. Start an LLM streaming request through the shared API remote runtime path. 3. Change Remote Runtime URL to server B while the stream is still active. 4. Abort/cancel the active stream. 5. Observe that the cancel path can target server B instead of server A, leaving the original server A stream uncancelled. If the cancel request fails, the failure is not surfaced in logs. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [x] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: observed in `origin/refactor` shared API cancellation path before the fix branch - Run mode: remote runtime - OS + version: not OS-specific from code inspection - Node + pnpm versions: not relevant - Rust version, if relevant: not relevant - Remote Runtime URL configured? yes - Provider, model, or integration, if relevant: LLM streaming path; provider/model agnostic ## Logs, screenshots, or video No user log attached. Code path evidence is in `src/shared/api/llm-api.ts` and `src/shared/api/remote-runtime.ts`. ## Regression notes Unknown. This appears to be an existing edge case in the current refactor branch cancellation flow. ## Additional context A fix should capture the remote runtime target once at stream start, use that same target for both streaming and cancellation, and preserve best-effort cancellation while logging sanitized cancel failures. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:30:47 +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#615
No description provided.