Skip to content

fix(graph): preserve matched nodes when source exceeds output budget - #239

Merged
theyashasvipandey merged 2 commits into
mex-memory:mainfrom
iveteamorim:fix/graph-get-output-budget
Sep 24, 2026
Merged

theyashasvipandey merged 2 commits into
mex-memory:mainfrom
iveteamorim:fix/graph-get-output-budget

Conversation

@iveteamorim

Copy link
Copy Markdown
Contributor

What

Fixes mex graph get <id> when a matched node's full source does not fit within the output budget.

Instead of dropping the node and reporting no-match, graph get now:

  • preserves the node's compact fact
  • returns the largest whole-line source prefix that fits the remaining budget
  • reports status: "partial" with truncated: true
  • suggests a larger --max-output-tokens value calculated to retrieve the full source

Successful source-backed graph get responses are unchanged.

Why

Fixes #230.

Previously, a node could exist and be matched while its source record exceeded the output budget. The source would be omitted, returnedNodes would fall to zero, and the summary would incorrectly report status: "no-match".

That makes a budget limitation indistinguishable from a missing node.

Type of change

  • Bug fix
  • Regression tests

Testing

  • Added regression coverage for an oversized matched node at the default 1500-token budget
  • Verifies a compact fact is returned
  • Verifies a truncated source prefix is returned within budget
  • Verifies the response is partial, not no-match
  • Verifies the suggested retry budget retrieves the full source
  • Added coverage for a tight valid output budget
  • protocol-v3-golden.test.ts: 4/4 passed
  • npm run typecheck: passed
  • npm run build: passed
  • git diff --check: passed

Existing successful graph get protocol goldens remain unchanged.

iveteamorim and others added 2 commits September 23, 2026 23:37
…nto the retry

When several ids exceed the budget, admit every omitted node's fact before
any source prefix spends the budget, so later nodes are not silently dropped.

The suggested retry budget is sized for the current --max-source-lines, so a
non-default cap is now included in the suggested command.
@theyashasvipandey

Copy link
Copy Markdown
Collaborator

Thanks @iveteamorim! I pushed a small follow-up commit (every oversized id now keeps its fact, and the retry suggestion keeps --max-source-lines). Merging.

@theyashasvipandey
theyashasvipandey merged commit 9d54c23 into mex-memory:main Sep 24, 2026
9 checks passed
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.

graph get reports no-match for existing nodes larger than the output budget

2 participants