Skip to content

perf: bound graph-memory recall token injection - #73

Open
Liyuk wants to merge 1 commit into
adoresever:mainfrom
Liyuk:perf/bound-recall-tokens
Open

perf: bound graph-memory recall token injection#73
Liyuk wants to merge 1 commit into
adoresever:mainfrom
Liyuk:perf/bound-recall-tokens

Conversation

@Liyuk

@Liyuk Liyuk commented Aug 17, 2026

Copy link
Copy Markdown

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant