Skip to content

feat: add output pagination to impact radius#39

Closed
n24q02m wants to merge 1 commit intotirth8205:mainfrom
n24q02m:feat/impact-radius-pagination
Closed

feat: add output pagination to impact radius#39
n24q02m wants to merge 1 commit intotirth8205:mainfrom
n24q02m:feat/impact-radius-pagination

Conversation

@n24q02m
Copy link
Contributor

@n24q02m n24q02m commented Mar 20, 2026

Summary

On large codebases, get_impact_radius can return thousands of nodes, producing 500K+ character MCP responses that blow up context windows and cause timeouts.

This PR adds output pagination with truncation metadata:

  • max_results parameter (default: 500) caps impacted nodes returned
  • truncated boolean flag indicates when results are incomplete
  • total_impacted integer shows the full count before truncation
  • Summary includes truncation notice when active

The BFS traversal itself already had a max_nodes parameter in graph.py but it was not exposed to the tools layer, and the results lacked truncation metadata.

Changes

  • code_review_graph/graph.py: get_impact_radius() now returns truncated and total_impacted in results dict
  • code_review_graph/tools.py: get_impact_radius() adds max_results parameter, passes to graph layer, includes truncation info in summary and response

Test plan

  • Impact radius with 100+ impacted nodes and max_results=10 returns exactly 10 nodes with truncated=True
  • Impact radius with few impacted nodes returns all with truncated=False
  • Default max_results=500 does not change behavior for small codebases
  • Existing tests pass

Add truncation metadata to get_impact_radius results and expose
max_results parameter in the tools layer.

On large codebases, impact radius can return thousands of nodes,
producing 500K+ character MCP responses that blow up context windows.
Now results are capped at max_results (default 500) with truncated
flag and total_impacted count so the caller knows when results are
incomplete.

Changes:
- graph.py: get_impact_radius returns truncated/total_impacted
- tools.py: get_impact_radius adds max_results parameter, passes
  to graph layer, includes truncation info in summary

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
tirth8205 added a commit that referenced this pull request Mar 20, 2026
- Multi-word AND search logic for search_nodes (#37 by n24q02m)
- Resolve same-file bare call targets to qualified names (#38 by n24q02m)
- Output pagination with truncation flag for impact radius (#39 by n24q02m)
- Update tests to handle qualified call targets from _resolve_call_targets

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tirth8205
Copy link
Owner

Integrated into main via a344eaf. Thanks for the contribution! Impact radius pagination with truncation flag is now live.

@tirth8205 tirth8205 closed this Mar 20, 2026
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.

2 participants