[GH-ISSUE #2687] [Issue]: Agents report success while silently dropping/corrupting output (knowledge-retrieval multi-pass + truncation, Spotify retry) #1332

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

Originally created by @kolacheee on GitHub (Jun 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2687

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Several agent paths report success while silently dropping or corrupting their output, so the user sees no error but the agent's contribution is empty/partial/fake: (a) the knowledge-retrieval multi-pass branch ignores per-chunk failures and hardcodes success:true with empty injection; (b) oversize source material is silently truncated mid-block by the provider context-fitter; (c) the Spotify Music-DJ retry swallows a credential failure into a false "recovered" success with no playback.

Expected behavior

When an agent's API call fails (bad key, model-rejected params, HTTP error) or its output is truncated/unusable, that should surface as a failure (or at least a warning) and behave consistently with the single-pass / main paths — not be reported as a clean success.

Actual behavior

(a) knowledge-retrieval multi-pass loops chunks calling executeAgent and accumulates only tokensUsed/durationMs; it never inspects result.success/result.error, and the final return hardcodes success:true, error:null. Since executeAgent returns success:false (via makeError) rather than throwing, a fully-failed multi-pass run returns success:true with data.text=''. The caller only handles thrown errors, so no agent_error fires and all retrieved lore is silently dropped. The single-pass branch (which returns executeAgent(...) directly) correctly surfaces the failure — so it's intermittent (only fires when material is large enough to chunk).

(b) The KR message array packs the entire <source_material> into one system message; when it overflows a small-but-set agent maxContext, the provider fitter's last-resort loop truncates the largest system message's tail, cutting later source entries and the closing tag. The agent summarizes only the surviving prefix and reports success.

(c) Spotify retry calls resolveSpotifyCredentials once; on failure it only logger.warns and leaves spotifyAccessToken null but still wires a full tool context. Every tool call returns {error} to the model instead of aborting; __spotifyToolError is never set on the retry route; and validateSpotifyRetryPlayback returns the result unchanged for non-game (roleplay) retries — so the model's JSON play-intent is returned success:true with no playback. The main path wires the same error into __spotifyToolError → success=false; the retry path doesn't.

How it breaks the pipeline

Code trace (staging @ b826f8f4):

  • (a) packages/server/src/services/agents/knowledge-retrieval.ts:102-138 (loop ignores result.success; hardcoded success:true :129-138); single-pass return at :77; executeAgent returns makeError not throw (agent-executor.ts:420-433,:938-948); caller generate.routes.ts:4852-4892 (only catches throws), injection consumer :5068-5082.
  • (b) packages/server/src/services/llm/base-provider.ts:441-505 (last-resort truncateContent on the largest system message); KR [system,user] array at agent-executor.ts:1132-1136; single-pass threshold default 6000 (knowledge-retrieval.ts).
  • (c) packages/server/src/routes/generate/retry-agents-route.ts:1342-1351 (cred failure only logged), :1378-1382 (tool guard returns {error}), :1608-1621 (validateSpotifyRetryPlayback returns unchanged for non-game). Contrast main path spotify-agent-runtime.ts:384-386 (isBlockingSpotifyToolError).

Steps to reproduce

  • (a) KR agent with an invalid per-agent key + a lorebook large enough that estimateTokens(source) > sourceContextBudget (default 6000) so the multi-pass branch runs → UI shows the agent succeeded, no error, zero lore injected. Same broken connection with smaller material (single-pass) correctly shows failure.
  • (b) Set the agent connection maxContext ~4096 with ~5000 est-tokens of source → the fitter truncates the source tail; the agent returns a summary built only from the first entries, reported as success.
  • (c) Music DJ (Spotify) agent with an expired/undecryptable token; trigger a manual Music DJ retry in roleplay mode → every tool call returns {error}, the model emits a play intent, and the UI shows a "recovered" result with no actual playback.

Suggested fix

  • (a) Track per-chunk result.success/result.error in the loop; in the final return set success based on whether any chunk failed and/or finalText is empty, and propagate error (e.g. "all extraction passes failed"). Optionally bail early on the first failure.
  • (b) Make executeKnowledgeRetrieval's budget the source of truth for chunking (clamp to maxContext) so the lossless chunker handles oversize material instead of the provider's lossy last-resort truncation.
  • (c) On credential-resolution failure, set a blocking flag (e.g. __spotifyToolError) on the spotify entry and, in validateSpotifyRetryPlayback, return { ...result, success:false, error } for a blocking credential error regardless of mode — mirroring isBlockingSpotifyToolError on the main path.

Environment

  • Marinara Engine version: 2.0.0 (staging @ b826f8f4)
  • Install type: source
  • OS + version: All (code-level defect, platform-independent)
  • Browser or app shell: All

Additional context

Found via a systematic multi-agent audit of the agent subsystem. All three are "agent reports success while its output is empty/partial/fake," making failures invisible and hard to diagnose. (b) requires a misconfigured low maxContext; (a) and (c) are reachable on common configs. Part of a set of agent-pipeline issues filed together.

Template check

Please uncheck (untick) 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 @kolacheee on GitHub (Jun 20, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2687 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Several agent paths report **success while silently dropping or corrupting their output**, so the user sees no error but the agent's contribution is empty/partial/fake: **(a)** the knowledge-retrieval multi-pass branch ignores per-chunk failures and hardcodes `success:true` with empty injection; **(b)** oversize source material is silently truncated mid-block by the provider context-fitter; **(c)** the Spotify Music-DJ *retry* swallows a credential failure into a false "recovered" success with no playback. ## Expected behavior When an agent's API call fails (bad key, model-rejected params, HTTP error) or its output is truncated/unusable, that should surface as a failure (or at least a warning) and behave consistently with the single-pass / main paths — not be reported as a clean success. ## Actual behavior **(a) knowledge-retrieval multi-pass** loops chunks calling `executeAgent` and accumulates only `tokensUsed`/`durationMs`; it never inspects `result.success`/`result.error`, and the final return **hardcodes `success:true, error:null`**. Since `executeAgent` returns `success:false` (via `makeError`) rather than throwing, a fully-failed multi-pass run returns `success:true` with `data.text=''`. The caller only handles thrown errors, so no `agent_error` fires and all retrieved lore is silently dropped. The single-pass branch (which returns `executeAgent(...)` directly) correctly surfaces the failure — so it's intermittent (only fires when material is large enough to chunk). **(b)** The KR message array packs the entire `<source_material>` into one system message; when it overflows a *small-but-set* agent `maxContext`, the provider fitter's last-resort loop truncates the largest system message's tail, cutting later source entries and the closing tag. The agent summarizes only the surviving prefix and reports success. **(c) Spotify retry** calls `resolveSpotifyCredentials` once; on failure it only `logger.warn`s and leaves `spotifyAccessToken` null but still wires a full tool context. Every tool call returns `{error}` to the model instead of aborting; `__spotifyToolError` is never set on the retry route; and `validateSpotifyRetryPlayback` returns the result unchanged for non-game (roleplay) retries — so the model's JSON play-intent is returned `success:true` with no playback. The **main** path wires the same error into `__spotifyToolError` → `success=false`; the retry path doesn't. ## How it breaks the pipeline Code trace (staging @ `b826f8f4`): - (a) `packages/server/src/services/agents/knowledge-retrieval.ts:102-138` (loop ignores `result.success`; hardcoded `success:true` `:129-138`); single-pass return at `:77`; `executeAgent` returns `makeError` not throw (`agent-executor.ts:420-433`,`:938-948`); caller `generate.routes.ts:4852-4892` (only catches throws), injection consumer `:5068-5082`. - (b) `packages/server/src/services/llm/base-provider.ts:441-505` (last-resort `truncateContent` on the largest system message); KR `[system,user]` array at `agent-executor.ts:1132-1136`; single-pass threshold default 6000 (`knowledge-retrieval.ts`). - (c) `packages/server/src/routes/generate/retry-agents-route.ts:1342-1351` (cred failure only logged), `:1378-1382` (tool guard returns `{error}`), `:1608-1621` (`validateSpotifyRetryPlayback` returns unchanged for non-game). Contrast main path `spotify-agent-runtime.ts:384-386` (`isBlockingSpotifyToolError`). ## Steps to reproduce - (a) KR agent with an invalid per-agent key + a lorebook large enough that `estimateTokens(source) > sourceContextBudget` (default 6000) so the multi-pass branch runs → UI shows the agent succeeded, no error, zero lore injected. Same broken connection with smaller material (single-pass) correctly shows failure. - (b) Set the agent connection `maxContext` ~4096 with ~5000 est-tokens of source → the fitter truncates the source tail; the agent returns a summary built only from the first entries, reported as success. - (c) Music DJ (Spotify) agent with an expired/undecryptable token; trigger a manual Music DJ retry in **roleplay** mode → every tool call returns `{error}`, the model emits a play intent, and the UI shows a "recovered" result with no actual playback. ## Suggested fix - (a) Track per-chunk `result.success`/`result.error` in the loop; in the final return set `success` based on whether any chunk failed and/or `finalText` is empty, and propagate `error` (e.g. "all extraction passes failed"). Optionally bail early on the first failure. - (b) Make `executeKnowledgeRetrieval`'s budget the source of truth for chunking (clamp to `maxContext`) so the lossless chunker handles oversize material instead of the provider's lossy last-resort truncation. - (c) On credential-resolution failure, set a blocking flag (e.g. `__spotifyToolError`) on the spotify entry and, in `validateSpotifyRetryPlayback`, return `{ ...result, success:false, error }` for a blocking credential error **regardless of mode** — mirroring `isBlockingSpotifyToolError` on the main path. ## Environment - Marinara Engine version: 2.0.0 (staging @ `b826f8f4`) - Install type: source - OS + version: All (code-level defect, platform-independent) - Browser or app shell: All ## Additional context Found via a systematic multi-agent audit of the agent subsystem. All three are "agent reports success while its output is empty/partial/fake," making failures invisible and hard to diagnose. (b) requires a misconfigured low `maxContext`; (a) and (c) are reachable on common configs. Part of a set of agent-pipeline issues filed together. ## Template check Please **uncheck (untick)** 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.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 21, 2026):

Addressed on the issue-sweep branch. Knowledge-retrieval multi-pass now sizes chunks against the provider context window before sending, splits oversized individual entries, and propagates per-pass failures into the final AgentResult instead of hardcoding success. Spotify manual retry now records credential/tool failures as __spotifyToolError and validates blocking Spotify errors before mode-specific playback checks, so roleplay retries no longer report recovered success with no playback. Final repo checks will run after the sweep.

<!-- gh-comment-id:4761495060 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Addressed on the issue-sweep branch. Knowledge-retrieval multi-pass now sizes chunks against the provider context window before sending, splits oversized individual entries, and propagates per-pass failures into the final AgentResult instead of hardcoding success. Spotify manual retry now records credential/tool failures as __spotifyToolError and validates blocking Spotify errors before mode-specific playback checks, so roleplay retries no longer report recovered success with no playback. Final repo checks will run after the sweep.
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#1332
No description provided.