mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2643] [Issue]: multi-pass knowledge retrieval double-injects facts when a middle chunk returns empty #1303
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#1303
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 @Romuromylus on GitHub (Jun 19, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2643
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Low — correctness. In the chunked (multi-pass) knowledge-retrieval path, the post-loop fallback uses
extractions.length < chunks.lengthas the proxy for "final consolidation missing." But a chunk can be absent fromextractions[]simply because it returned"No relevant information found."When exactly one non-final chunk is empty, the fallback concatenates the raw partial extractions plus the final consolidated extraction (which already merged those partials), double-injecting the same facts.Expected behavior
When the final consolidation pass produces output, only the consolidated text should be injected. Raw per-chunk partials should be concatenated only when the consolidation pass itself produced nothing.
Actual behavior
packages/server/src/services/agents/knowledge-retrieval.ts— an empty chunk is filtered at line 104 and never pushed (105). The final chunk runs with_previousExtractions, and the agent prompt (agent-executor.ts:1757–1768) instructs the model to "Consolidate them into a single, coherent summary along with any new relevant information from the current chunk" — so the final extraction already incorporates the earlier partials. The post-loop branch:is entered whenever any non-final chunk was empty even though consolidation succeeded — so
combinedis the raw partials concatenated with the consolidation that already contains them, double-injecting the facts.Steps to reproduce
sourceContextBudget)."No relevant information found."while the others (including the final consolidation pass) produce text.context_injectiontext contains the same facts twice.Environment
staging @ 3dc062e2Logs, screenshots, or video
Static source audit, cited to file:line above.
Additional context
Fix sketch: track consolidation success with an explicit boolean rather than inferring it from
extractions.lengthvschunks.length. When the final consolidation pass produced output, return only the consolidated text; fall back to concatenating raw partials only when the consolidation pass itself produced nothing.Regression notes: not a regression —
knowledge-retrieval.tsis byte-identical onstagingandmain; this is a long-standing shared-code bug. Effect is wasted prompt tokens / redundant context, not data loss. Found via static audit.Template check
@Romuromylus commented on GitHub (Jun 19, 2026):
Sibling of #2642 — both live in the knowledge-retrieval path (
knowledge-retrieval.ts/knowledge-sources.routes.ts). Grouped with #2639, #2640, #2641 into one agents-subsystem hardening PR.