[GH-ISSUE #4767] [Feature]: Make workspace assistant output limits configurable and adequate for power-user workflows #2624

Closed
opened 2026-10-21 05:51:38 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @xDanteMD on GitHub (Aug 8, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4767

Originally assigned to: @kolacheee on GitHub.

What problem does this solve?

The workspace assistant (Professor Mari on the Home screen) has hardcoded output limits tuned for casual usage that silently break for power users with large collections or complex tasks. The primary culprit is COMMAND_OUTPUT_LIMIT = 32,000 characters (~8K tokens), which truncates app_data command output mid-field without warning.

The 32K output limit is 0.8% of a 1M context window. The model has 1,000,000 tokens of context available, but the application limits tool output to ~8,000 tokens. The remaining 992,000 tokens are unused.

Affected limits

Limit Value Location Impact
COMMAND_OUTPUT_LIMIT 32,000 chars (~8K tokens) workspace-agent.service.ts:157 Character cards with 20+ greetings truncated mid-field
Command round limit (undocumented) workspace-agent.service.ts Complex multi-entity tasks (10 lorebooks, 10 greetings) hit the round cap before completion
OS sandbox (win32) Disabled Platform-dependent No mari db fallback for raw DB access on Windows — users have no workaround when structured tools hit limits

Reproduction: character cards with large data

A character with 20 alternate greetings (~750 tokens each, ~3,000 characters each) produces a JSON output of ~60,000+ characters. The compactOutput function (workspace-agent.service.ts:692-694) slices it at 32,000 characters:

// workspace-agent.service.ts:157
const COMMAND_OUTPUT_LIMIT = 32_000;

// workspace-agent.service.ts:692-694
function compactOutput(value: string, limit = COMMAND_OUTPUT_LIMIT): string {
  return value.length > limit ? `${value.slice(0, limit)}\n… output truncated at ${limit} characters …` : value;
}

Steps to reproduce:

  1. Create or import a character with 20+ alternate greetings (each ~750 tokens / ~3,000 characters)
  2. Open the workspace assistant (Home screen)
  3. Ask Mari to fetch the character: app_data character.get with the character's ID
  4. Observe: the output is truncated at 32,000 characters, cutting off mid-way through the alternate_greetings array
  5. Ask Mari to add more greetings — she cannot see the existing ones past the truncation point

The character.get handler (mari-db.service.ts:1762-1766) returns the full parsed row including all fields. The executeAction dispatcher (mari-db.service.ts:1696-1727) routes to executeCharacterAction (mari-db.service.ts:1729-1931), which calls parseRow (mari-db.service.ts:411-418) to reconstruct the full card. The truncation happens in the output formatting layer, not in data retrieval. The workspace assistant's structured tool protocol (app_data) correctly returns the full data — the issue is purely in the output size limit.

Real-world failure mode

  1. User asks workspace Mari to add 10 alternate greetings to a character
  2. Mari fetches the character card via app_data character.get
  3. The card (with existing greetings) is truncated at 32K characters
  4. Mari cannot see the full card — greetings are cut off mid-field
  5. Mari generates new greetings, but cannot verify the full state
  6. Mari reports "success" — but the greetings either weren't added or were duplicated
  7. User discovers the failure when re-fetching the card

The LLM's own diagnosis (from a live session): "Root cause: the read cap (32k chars) hit before the alternate_greetings array finished."

Impact

  • Data loss in context: The model cannot see the full character card, leading to incomplete edits, duplicate greetings, or failed verification
  • Silent truncation: The model receives a truncated JSON with no structured metadata about what was cut — it just sees an incomplete object
  • No workaround on Windows: The OS sandbox disables shell access, so mari db (raw DB fallback) is unavailable. Users have no fallback when the structured tools hit limits
  • Compounds with other issues: Combined with the regex parser fragility (#3) and the lack of a feedback loop, the model has no way to know it's working with incomplete data
  • Broad impact: The limit applies to ALL app_data actions, not just character.get. Lorebook entries, preset sections, and other large entities hit the same truncation

Proposed solution

Option A: Per-action limits (recommended starting point)

Read operations (character.get, lorebook.get, preset.get) use a higher limit (e.g., 100,000 characters or no limit). Write operations keep the current limit. This matches the principle that reads are cheap and writes need verification. The data is already in memory — there's no performance cost to returning it. This directly addresses the truncation bug without changing the safety net for writes.

Option B: Dynamic limits based on context window (recommended long-term)

Scale COMMAND_OUTPUT_LIMIT based on the connection's maxContext:

  • For 1M context: allow up to 200K chars of tool output
  • For 128K context: allow up to 32K chars (current default)
  • For 8K context: keep current limits

This automatically adapts to the user's model capabilities. Prior art: the maxContext value is already available on the connection object and used by fitMessagesToContext() (base-provider.ts).

Option C: User-configurable settings

Add a "Workspace Limits" section to Settings > Advanced:

  • Expose COMMAND_OUTPUT_LIMIT (default: 32,000, recommended: 100,000+)
  • Expose command round limit (default: current, recommended: 2x for power users)
  • Document the trade-offs (higher limits = more tokens per turn)

Option D: Field-aware truncation (complementary)

Instead of slicing at a character boundary, truncate after complete JSON fields. This prevents broken JSON but still loses data. Best combined with A, B, or C — it's a defensive improvement that reduces damage from truncation rather than preventing it.

Recommended: Option A + B combined. Per-action limits for immediate relief, with dynamic scaling as the long-term solution.

Alternatives considered

  • Keep current limits — breaks power users. A user with 20 greetings per character cannot use the workspace assistant to manage them.
  • Increase limit globally — works but wastes tokens for users with small context models. Configurable or dynamic is better.
  • Remove the limit entirely — risky. Unbounded output could overwhelm small context models. Better to scale dynamically or make configurable.
  • Return summary + full data separately — for character.get, return a summary object (name, description, tags) plus the full data. The model can request specific fields if needed. Complementary to raising the limit but adds API complexity.
  • Add a "compact mode" — return summaries for large entities (name, description, tags only). The model can request full data when needed. Complementary to raising the limit.
  • #4673 (Prof Mari receives truncated lorebook entries): Same root cause pattern — tool output truncated for large entities, with shell fallback unavailable on Windows. Fixed in staging but confirms the truncation issue extends beyond character cards to lorebooks, presets, and other large app_data entities. The fix in #4673 addressed lorebook-specific handling; this issue requests a systemic fix for the underlying COMMAND_OUTPUT_LIMIT.
  • #3864 (Remove hidden hard constraints): Explicit power-user request to remove arbitrary upper limits (away check-in caps, 50-message summarization limit, etc.) that prevent advanced users from utilizing large context windows. Same philosophy — hardcoded limits that made sense for small contexts don't scale.
  • #2857 / PR #2858 (Mari Chat helper 500-char / 200-message limits): Previously hardcoded output limits on Mari Chat helper (500 characters, 200 messages). Fixed by removing the limits entirely. Precedent for this approach — the team has already removed similar hardcoded caps when they proved too restrictive.
  • #4390 (Workspace loop accepts unverified 'done'): The workspace assistant's verification gap means truncated output goes undetected — the model reports success without verifying it can see the full data. Combined with the 32K truncation, this creates a compounding failure: data is truncated AND the model doesn't know it's truncated. Fixed in staging (four-layer verification), but verification still can't detect truncation when the truncated data silently fits a partial JSON structure.
  • #2288 (useMaxContext flag never honored): Prompt fitting used hardcoded 128K instead of the model's real context window. Related to Option B (dynamic limits based on maxContext) — the maxContext plumbing has had reliability issues, which is worth considering when building dynamic scaling on top of it.
  • #2687 (Agents report success while silently dropping/corrupting output): Agents silently truncate oversized source material and hardcode success: true even on failure. Same class of problem — silent truncation with no structured error reporting. The workspace assistant's compactOutput truncation is a specific instance of this broader pattern.

Additional context

  • The commandAppData function (workspace-agent.service.ts:2722-2745) is the entry point for all app_data commands. The limit is applied after the command returns, meaning the data is fully fetched before being sliced.
  • On Windows (win32), the OS sandbox disables shell access, so mari db (raw DB fallback) is unavailable. Users have no workaround when the structured tools hit limits.
  • The 32K limit was likely set as a safety net for token consumption. With modern models offering 128K–1M context windows, the safety net is now a bottleneck. The limit made sense when context windows were 8K–32K; it does not scale with current capabilities.

Research undertaken: codebase analysis of workspace-agent.service.ts (COMMAND_OUTPUT_LIMIT at line 157, compactOutput at lines 692-694, commandAppData at lines 2722-2745), mari-db.service.ts (executeAction at lines 1696-1727, executeCharacterAction at lines 1729-1931, character.get handler at lines 1762-1766, parseRow at lines 411-418). Real-world testing with a character card containing 20 alternate greetings (~60K characters). LLM's own diagnosis confirmed the 32K read cap as root cause. Traced the full data flow: commandAppData → executeAction → executeCharacterAction → parseRow → full data returned → compactOutput truncates at 32K. The truncation is purely in the output formatting layer — the data retrieval is correct. Repo-wide search for related issues: #4673 (truncated lorebook entries, same root cause), #3864 (remove hidden hard constraints, same philosophy), #2857/#2858 (500-char output limit, precedent fix), #4390 (unverified done, compounding failure), #2288 (useMaxContext not honored, maxContext plumbing issues), #2687 (silent agent output corruption, same pattern). Prior research documented in github-issues/README.md (workspace-agent analysis across lines 220-600, 1200-1260, 1499-1590, 1846-2060; mari-db.service analysis for executeAction and character action handlers).

Originally created by @xDanteMD on GitHub (Aug 8, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4767 Originally assigned to: @kolacheee on GitHub. ## What problem does this solve? The workspace assistant (Professor Mari on the Home screen) has hardcoded output limits tuned for casual usage that silently break for power users with large collections or complex tasks. The primary culprit is `COMMAND_OUTPUT_LIMIT = 32,000` characters (~8K tokens), which truncates `app_data` command output mid-field without warning. **The 32K output limit is 0.8% of a 1M context window.** The model has 1,000,000 tokens of context available, but the application limits tool output to ~8,000 tokens. The remaining 992,000 tokens are unused. ### Affected limits | Limit | Value | Location | Impact | | --- | --- | --- | --- | | `COMMAND_OUTPUT_LIMIT` | 32,000 chars (~8K tokens) | `workspace-agent.service.ts:157` | Character cards with 20+ greetings truncated mid-field | | Command round limit | (undocumented) | `workspace-agent.service.ts` | Complex multi-entity tasks (10 lorebooks, 10 greetings) hit the round cap before completion | | OS sandbox (win32) | Disabled | Platform-dependent | No `mari db` fallback for raw DB access on Windows — users have no workaround when structured tools hit limits | ### Reproduction: character cards with large data A character with 20 alternate greetings (~750 tokens each, ~3,000 characters each) produces a JSON output of ~60,000+ characters. The `compactOutput` function (`workspace-agent.service.ts:692-694`) slices it at 32,000 characters: ```ts // workspace-agent.service.ts:157 const COMMAND_OUTPUT_LIMIT = 32_000; // workspace-agent.service.ts:692-694 function compactOutput(value: string, limit = COMMAND_OUTPUT_LIMIT): string { return value.length > limit ? `${value.slice(0, limit)}\n… output truncated at ${limit} characters …` : value; } ``` Steps to reproduce: 1. Create or import a character with 20+ alternate greetings (each ~750 tokens / ~3,000 characters) 2. Open the workspace assistant (Home screen) 3. Ask Mari to fetch the character: `app_data character.get` with the character's ID 4. Observe: the output is truncated at 32,000 characters, cutting off mid-way through the alternate_greetings array 5. Ask Mari to add more greetings — she cannot see the existing ones past the truncation point The `character.get` handler (`mari-db.service.ts:1762-1766`) returns the full parsed row including all fields. The `executeAction` dispatcher (`mari-db.service.ts:1696-1727`) routes to `executeCharacterAction` (`mari-db.service.ts:1729-1931`), which calls `parseRow` (`mari-db.service.ts:411-418`) to reconstruct the full card. **The truncation happens in the output formatting layer, not in data retrieval.** The workspace assistant's structured tool protocol (`app_data`) correctly returns the full data — the issue is purely in the output size limit. ### Real-world failure mode 1. User asks workspace Mari to add 10 alternate greetings to a character 2. Mari fetches the character card via `app_data character.get` 3. The card (with existing greetings) is truncated at 32K characters 4. Mari cannot see the full card — greetings are cut off mid-field 5. Mari generates new greetings, but cannot verify the full state 6. Mari reports "success" — but the greetings either weren't added or were duplicated 7. User discovers the failure when re-fetching the card The LLM's own diagnosis (from a live session): *"Root cause: the read cap (32k chars) hit before the alternate_greetings array finished."* ### Impact - **Data loss in context:** The model cannot see the full character card, leading to incomplete edits, duplicate greetings, or failed verification - **Silent truncation:** The model receives a truncated JSON with no structured metadata about what was cut — it just sees an incomplete object - **No workaround on Windows:** The OS sandbox disables shell access, so `mari db` (raw DB fallback) is unavailable. Users have no fallback when the structured tools hit limits - **Compounds with other issues:** Combined with the regex parser fragility (#3) and the lack of a feedback loop, the model has no way to know it's working with incomplete data - **Broad impact:** The limit applies to ALL `app_data` actions, not just `character.get`. Lorebook entries, preset sections, and other large entities hit the same truncation ## Proposed solution **Option A: Per-action limits (recommended starting point)** Read operations (`character.get`, `lorebook.get`, `preset.get`) use a higher limit (e.g., 100,000 characters or no limit). Write operations keep the current limit. This matches the principle that reads are cheap and writes need verification. The data is already in memory — there's no performance cost to returning it. This directly addresses the truncation bug without changing the safety net for writes. **Option B: Dynamic limits based on context window (recommended long-term)** Scale `COMMAND_OUTPUT_LIMIT` based on the connection's `maxContext`: - For 1M context: allow up to 200K chars of tool output - For 128K context: allow up to 32K chars (current default) - For 8K context: keep current limits This automatically adapts to the user's model capabilities. Prior art: the `maxContext` value is already available on the connection object and used by `fitMessagesToContext()` (`base-provider.ts`). **Option C: User-configurable settings** Add a "Workspace Limits" section to Settings > Advanced: - Expose `COMMAND_OUTPUT_LIMIT` (default: 32,000, recommended: 100,000+) - Expose command round limit (default: current, recommended: 2x for power users) - Document the trade-offs (higher limits = more tokens per turn) **Option D: Field-aware truncation (complementary)** Instead of slicing at a character boundary, truncate after complete JSON fields. This prevents broken JSON but still loses data. Best combined with A, B, or C — it's a defensive improvement that reduces damage from truncation rather than preventing it. **Recommended: Option A + B combined.** Per-action limits for immediate relief, with dynamic scaling as the long-term solution. ## Alternatives considered - **Keep current limits** — breaks power users. A user with 20 greetings per character cannot use the workspace assistant to manage them. - **Increase limit globally** — works but wastes tokens for users with small context models. Configurable or dynamic is better. - **Remove the limit entirely** — risky. Unbounded output could overwhelm small context models. Better to scale dynamically or make configurable. - **Return summary + full data separately** — for `character.get`, return a summary object (name, description, tags) plus the full data. The model can request specific fields if needed. Complementary to raising the limit but adds API complexity. - **Add a "compact mode"** — return summaries for large entities (name, description, tags only). The model can request full data when needed. Complementary to raising the limit. ## Related issues - **#4673 (Prof Mari receives truncated lorebook entries):** Same root cause pattern — tool output truncated for large entities, with shell fallback unavailable on Windows. Fixed in staging but confirms the truncation issue extends beyond character cards to lorebooks, presets, and other large `app_data` entities. The fix in #4673 addressed lorebook-specific handling; this issue requests a systemic fix for the underlying `COMMAND_OUTPUT_LIMIT`. - **#3864 (Remove hidden hard constraints):** Explicit power-user request to remove arbitrary upper limits (away check-in caps, 50-message summarization limit, etc.) that prevent advanced users from utilizing large context windows. Same philosophy — hardcoded limits that made sense for small contexts don't scale. - **#2857 / PR #2858 (Mari Chat helper 500-char / 200-message limits):** Previously hardcoded output limits on Mari Chat helper (500 characters, 200 messages). Fixed by removing the limits entirely. Precedent for this approach — the team has already removed similar hardcoded caps when they proved too restrictive. - **#4390 (Workspace loop accepts unverified 'done'):** The workspace assistant's verification gap means truncated output goes undetected — the model reports success without verifying it can see the full data. Combined with the 32K truncation, this creates a compounding failure: data is truncated AND the model doesn't know it's truncated. Fixed in staging (four-layer verification), but verification still can't detect truncation when the truncated data silently fits a partial JSON structure. - **#2288 (useMaxContext flag never honored):** Prompt fitting used hardcoded 128K instead of the model's real context window. Related to Option B (dynamic limits based on `maxContext`) — the `maxContext` plumbing has had reliability issues, which is worth considering when building dynamic scaling on top of it. - **#2687 (Agents report success while silently dropping/corrupting output):** Agents silently truncate oversized source material and hardcode `success: true` even on failure. Same class of problem — silent truncation with no structured error reporting. The workspace assistant's `compactOutput` truncation is a specific instance of this broader pattern. ## Additional context - The `commandAppData` function (`workspace-agent.service.ts:2722-2745`) is the entry point for all `app_data` commands. The limit is applied after the command returns, meaning the data is fully fetched before being sliced. - On Windows (win32), the OS sandbox disables shell access, so `mari db` (raw DB fallback) is unavailable. Users have no workaround when the structured tools hit limits. - The 32K limit was likely set as a safety net for token consumption. With modern models offering 128K–1M context windows, the safety net is now a bottleneck. The limit made sense when context windows were 8K–32K; it does not scale with current capabilities. --- *Research undertaken: codebase analysis of `workspace-agent.service.ts` (COMMAND_OUTPUT_LIMIT at line 157, compactOutput at lines 692-694, commandAppData at lines 2722-2745), `mari-db.service.ts` (executeAction at lines 1696-1727, executeCharacterAction at lines 1729-1931, character.get handler at lines 1762-1766, parseRow at lines 411-418). Real-world testing with a character card containing 20 alternate greetings (~60K characters). LLM's own diagnosis confirmed the 32K read cap as root cause. Traced the full data flow: commandAppData → executeAction → executeCharacterAction → parseRow → full data returned → compactOutput truncates at 32K. The truncation is purely in the output formatting layer — the data retrieval is correct. Repo-wide search for related issues: #4673 (truncated lorebook entries, same root cause), #3864 (remove hidden hard constraints, same philosophy), #2857/#2858 (500-char output limit, precedent fix), #4390 (unverified done, compounding failure), #2288 (useMaxContext not honored, maxContext plumbing issues), #2687 (silent agent output corruption, same pattern). Prior research documented in github-issues/README.md (workspace-agent analysis across lines 220-600, 1200-1260, 1499-1590, 1846-2060; mari-db.service analysis for executeAction and character action handlers).*
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#2624
No description provided.