Skip to content

feat(mcp): optional limit on callers, callees, and impact#34

Merged
solomonneas merged 2 commits into
masterfrom
bench/tool-surface-shape
Jul 17, 2026
Merged

feat(mcp): optional limit on callers, callees, and impact#34
solomonneas merged 2 commits into
masterfrom
bench/tool-surface-shape

Conversation

@solomonneas

Copy link
Copy Markdown
Contributor

What

Adds an optional limit argument to the callers, callees, and impact MCP tools. When set, the edge list is cut to the first N real edges and one marker row is appended reporting shown vs total (results limited to 5 of 79 edges). When omitted, output is byte-for-byte identical to before.

Why

A tool-surface benchmark (receipts in benchmarks/tool-surface/) measured the typed tools against a single bounded-search surface on the same 12-question set. Typed tools won on answers (11/12 vs 4/12) but had no per-call size lever: impact on a hot symbol emitted ~9,150 tokens and callers ~7,460 in one call, against the internal 500-per-direction safety cap only. An agent on a token budget needs to bound a blast-radius query the same way it bounds a search.

Measured on this repo: callers sync_repo unbounded = 79 edges / 33,479 chars; limit: 5 = 5 edges + marker / 2,267 chars.

How

  • limit_edges(edges, Option<usize>) in src/query/graph.rs: pure function, None passthrough, counts only real edges, drops any pre-existing cap marker on truncation, appends one TRUNCATED_EDGE_KIND sentinel.
  • Wired in src/mcp.rs dispatch for the three tools; limit added to the shared symbol-tool schema (optional) and validated like depth (absent ok, non-integer rejected).
  • Unit test limit_edges_truncates_and_reports_shown_vs_total.

Verification

cargo fmt --check, cargo clippy --all-targets --all-features -- -D warnings, cargo test --all-features, cargo build --release all pass (Brigade receipts 20260717-1926*). Live MCP session confirmed omitted-limit output unchanged and limit: 5 behavior above.

Blast-radius queries had no per-call size lever: impact on a hot symbol
returned every edge up to the fixed 500-per-direction cap (~9k tokens on
this repo). An optional limit now truncates the edge list and appends a
marker row reporting shown vs total. Omitting limit preserves the prior
output byte-for-byte.
@solomonneas solomonneas self-assigned this Jul 17, 2026
@solomonneas
solomonneas merged commit fb31cb0 into master Jul 17, 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.

1 participant