[GH-ISSUE #3773] [Issue]: Sidecar scene analysis rejects long narration instead of applying its context budget #2036

Closed
opened 2026-10-21 05:44:47 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Sidecar scene analysis rejects narration over 16,000 characters before inference, while connection-based scene analysis accepts up to 50,000 characters. The smaller sidecar budget appears appropriate for local inference, but it is enforced as an abrupt request failure rather than an explicit compaction policy, and the client plus both server routes maintain separate versions of the same base request contract.

Expected behavior

Long narration should be handled consistently and deliberately for the selected analyzer:

  • Preserve a sidecar-specific input budget suitable for its smaller context window.
  • Compact or truncate narration before inference, or prevent an oversized request with a clear user-facing explanation.
  • Define the common scene-analysis context/request shape once, while composing endpoint-specific fields and documented limits around it.

This is not a request to raise the sidecar limit to 50,000 characters.

Actual behavior

POST /api/sidecar/analyze-scene validates narration with z.string().max(16000). An oversized turn is rejected before the sidecar's existing context-fitting logic runs. The client then applies inline GM tags and displays the generic “Scene analysis failed” retry/skip UI.

POST /api/game/scene-wrap accepts the same narration up to 50,000 characters. It also differs from the sidecar route in required/default context fields and player-action limits. The client declares a third handwritten TypeScript request shape.

Steps to reproduce

  1. Enable Use for game scene analysis for the local sidecar.
  2. Complete a GM narration whose cleaned content is between 16,001 and 50,000 characters.
  3. Observe that /api/sidecar/analyze-scene is rejected by request validation and the UI falls back to inline tags with a scene-analysis failure message.
  4. Select a regular scene-analysis connection and repeat with the same narration; /api/game/scene-wrap accepts the request schema.

Environment

  • Marinara Engine version: staging 2.3.3 at de19d54e4bbb1c3555f89dbfae40999aa4f45712
  • Install type: Source inspection
  • OS + version: Not runtime-tested
  • Browser or app shell: Not runtime-tested

Logs, screenshots, or video

No runtime logs or screenshots. The failure is deterministically established by the route schemas and client error path.

Additional context

The 16,000-character limit is plausibly intentional rather than arbitrary:

  • The sidecar defaults to an 8,192-token context window in packages/shared/src/types/sidecar.ts.
  • Scene analysis reserves up to 4,096 output tokens in packages/server/src/services/sidecar/sidecar-inference.service.ts.
  • Roughly 16,000 narration characters are about 4,000 input tokens, before other prompt/context content.

Relevant contracts:

  • packages/client/src/hooks/use-scene-analysis.ts — handwritten client request type
  • packages/server/src/routes/sidecar.routes.ts — 16,000-character sidecar validation
  • packages/server/src/routes/game.routes.ts — 50,000-character connection validation

A narrow fix would share the base request/context schema and introduce one explicit narration-normalization function or policy. Endpoint-specific budgets can remain different, but should be named and tested as intentional behavior rather than drifting inline literals.

Duplicate search: no matching open or closed issue, or open pull request, was found for “scene analysis sidecar narration”, “16000”, “16k”, or “context budget”.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (Jul 18, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3773 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Sidecar scene analysis rejects narration over 16,000 characters before inference, while connection-based scene analysis accepts up to 50,000 characters. The smaller sidecar budget appears appropriate for local inference, but it is enforced as an abrupt request failure rather than an explicit compaction policy, and the client plus both server routes maintain separate versions of the same base request contract. ## Expected behavior Long narration should be handled consistently and deliberately for the selected analyzer: - Preserve a sidecar-specific input budget suitable for its smaller context window. - Compact or truncate narration before inference, or prevent an oversized request with a clear user-facing explanation. - Define the common scene-analysis context/request shape once, while composing endpoint-specific fields and documented limits around it. This is not a request to raise the sidecar limit to 50,000 characters. ## Actual behavior `POST /api/sidecar/analyze-scene` validates narration with `z.string().max(16000)`. An oversized turn is rejected before the sidecar's existing context-fitting logic runs. The client then applies inline GM tags and displays the generic “Scene analysis failed” retry/skip UI. `POST /api/game/scene-wrap` accepts the same narration up to 50,000 characters. It also differs from the sidecar route in required/default context fields and player-action limits. The client declares a third handwritten TypeScript request shape. ## Steps to reproduce 1. Enable **Use for game scene analysis** for the local sidecar. 2. Complete a GM narration whose cleaned content is between 16,001 and 50,000 characters. 3. Observe that `/api/sidecar/analyze-scene` is rejected by request validation and the UI falls back to inline tags with a scene-analysis failure message. 4. Select a regular scene-analysis connection and repeat with the same narration; `/api/game/scene-wrap` accepts the request schema. ## Environment - Marinara Engine version: `staging` 2.3.3 at `de19d54e4bbb1c3555f89dbfae40999aa4f45712` - Install type: Source inspection - OS + version: Not runtime-tested - Browser or app shell: Not runtime-tested ## Logs, screenshots, or video No runtime logs or screenshots. The failure is deterministically established by the route schemas and client error path. ## Additional context The 16,000-character limit is plausibly intentional rather than arbitrary: - The sidecar defaults to an 8,192-token context window in `packages/shared/src/types/sidecar.ts`. - Scene analysis reserves up to 4,096 output tokens in `packages/server/src/services/sidecar/sidecar-inference.service.ts`. - Roughly 16,000 narration characters are about 4,000 input tokens, before other prompt/context content. Relevant contracts: - `packages/client/src/hooks/use-scene-analysis.ts` — handwritten client request type - `packages/server/src/routes/sidecar.routes.ts` — 16,000-character sidecar validation - `packages/server/src/routes/game.routes.ts` — 50,000-character connection validation A narrow fix would share the base request/context schema and introduce one explicit narration-normalization function or policy. Endpoint-specific budgets can remain different, but should be named and tested as intentional behavior rather than drifting inline literals. Duplicate search: no matching open or closed issue, or open pull request, was found for “scene analysis sidecar narration”, “16000”, “16k”, or “context budget”. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:44:47 +07:00
  • closed this issue
  • added the
    in-pr
    label
Author
Owner

@SpicyMarinara commented on GitHub (Jul 18, 2026):

Addressed in #3775. The PR is ready for review, all required CI checks are green, and CodeRabbit feedback has been applied.

<!-- gh-comment-id:5010867725 --> @SpicyMarinara commented on GitHub (Jul 18, 2026): Addressed in #3775. The PR is ready for review, all required CI checks are green, and CodeRabbit feedback has been applied.
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#2036
No description provided.