fix: cap recall injection size to prevent context bloat in long sessions - #77
Open
evilh2019 wants to merge 1 commit into
Open
fix: cap recall injection size to prevent context bloat in long sessions#77evilh2019 wants to merge 1 commit into
evilh2019 wants to merge 1 commit into
Conversation
assembleContext was injecting ALL session-active nodes (411 in a long
session) with full content plus up to 500 raw messages per episodic trace,
producing ~310KB runtime-context per user message. That overflowed the
context window and let DSH compaction preempt in-flight tool calls
('tool call aborted' / TOOL_OUTCOME_UNKNOWN).
Fix: inject ONLY the query-targeted recall nodes (recalled <=
recallMaxNodes, semantic search already covers this session's relevant
nodes). Session-active nodes are no longer dumped by time; a 3-node
fallback covers the empty-recall case. Episodic traces are capped to
30 msgs x 120 chars per top node.
evilh2019
force-pushed
the
fix/recall-injection-bloat
branch
from
August 22, 2026 02:35
5193782 to
3c313d0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题 / Problem
assembleContext把 recalled 节点 + 本会话全部 active 节点(含 content 全文)+ 每节点最多 500 条原始消息的 episodic trace 全量注入 system prompt。在长会话中(本机单会话累积 411 个 active 节点),每次用户消息的 runtime-context 注入达到 ~310KB(约 10 万+ tokens),导致:
tool call aborted/TOOL_OUTCOME_UNKNOWN)修复 / Fix
src/format/assemble.ts加体量上限:recallMaxNodes限制,默认 6),active 节点只取 最近 15 个(按updatedAt排序)——防御长会话累积节点全量注入验证 / Verification