perf: bound graph-memory recall token injection - #73
Open
Liyuk wants to merge 1 commit into
Open
Conversation
Liyuk
commented
Aug 17, 2026
The recall context is injected on every prompt assembly. Several unbounded inputs let it grow with graph size: - tokenBudget was accepted but ignored (hardcoded 0): every recalled node was injected in full regardless of budget. - Node content was injected verbatim, including a leading name line that duplicates the XML name attribute. - Precise and generalized recall paths each ran to the full limit and were merged with only dedup, doubling node count (12 instead of 6). - Episodic provenance pulled top-3 nodes x 2 sessions at up to 500 chars. - System prompt boilerplate and per-node updated timestamps were verbose. Changes: - assemble.ts: enforce tokenBudget (greedy, highest-priority node first, always keeps >=1 node); strip the leading content name line; truncate content to contentMaxChars (default 400); tighten episodic to top-2 x 300 chars x 150 chars/msg; drop updated timestamps; condense the system prompt boilerplate. - recall.ts: precise path wins; the generalized path only backfills communities the precise path missed, capped at recallMaxNodes. - types.ts + dsh.ts + index.ts: wire recallTokenBudget (default 2000) and contentMaxChars (default 400) through config; 0 = unbounded (backward compatible). Measured on a real 897-node graph: 12->6 nodes/query and ~49% fewer injected tokens per query (2781->1424 avg). Recall quality is preserved because full node content stays available via gm_search.
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.