mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2687] [Issue]: Agents report success while silently dropping/corrupting output (knowledge-retrieval multi-pass + truncation, Spotify retry) #1332
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#1332
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?
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:truewith 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
executeAgentand accumulates onlytokensUsed/durationMs; it never inspectsresult.success/result.error, and the final return hardcodessuccess:true, error:null. SinceexecuteAgentreturnssuccess:false(viamakeError) rather than throwing, a fully-failed multi-pass run returnssuccess:truewithdata.text=''. The caller only handles thrown errors, so noagent_errorfires and all retrieved lore is silently dropped. The single-pass branch (which returnsexecuteAgent(...)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 agentmaxContext, 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
resolveSpotifyCredentialsonce; on failure it onlylogger.warns and leavesspotifyAccessTokennull but still wires a full tool context. Every tool call returns{error}to the model instead of aborting;__spotifyToolErroris never set on the retry route; andvalidateSpotifyRetryPlaybackreturns the result unchanged for non-game (roleplay) retries — so the model's JSON play-intent is returnedsuccess:truewith 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):packages/server/src/services/agents/knowledge-retrieval.ts:102-138(loop ignoresresult.success; hardcodedsuccess:true:129-138); single-pass return at:77;executeAgentreturnsmakeErrornot throw (agent-executor.ts:420-433,:938-948); callergenerate.routes.ts:4852-4892(only catches throws), injection consumer:5068-5082.packages/server/src/services/llm/base-provider.ts:441-505(last-resorttruncateContenton the largest system message); KR[system,user]array atagent-executor.ts:1132-1136; single-pass threshold default 6000 (knowledge-retrieval.ts).packages/server/src/routes/generate/retry-agents-route.ts:1342-1351(cred failure only logged),:1378-1382(tool guard returns{error}),:1608-1621(validateSpotifyRetryPlaybackreturns unchanged for non-game). Contrast main pathspotify-agent-runtime.ts:384-386(isBlockingSpotifyToolError).Steps to reproduce
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.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.{error}, the model emits a play intent, and the UI shows a "recovered" result with no actual playback.Suggested fix
result.success/result.errorin the loop; in the final return setsuccessbased on whether any chunk failed and/orfinalTextis empty, and propagateerror(e.g. "all extraction passes failed"). Optionally bail early on the first failure.executeKnowledgeRetrieval's budget the source of truth for chunking (clamp tomaxContext) so the lossless chunker handles oversize material instead of the provider's lossy last-resort truncation.__spotifyToolError) on the spotify entry and, invalidateSpotifyRetryPlayback, return{ ...result, success:false, error }for a blocking credential error regardless of mode — mirroringisBlockingSpotifyToolErroron the main path.Environment
b826f8f4)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:
@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.