Skip to content

Fixes #1542: Parameterize relationship query limits, add truncation flags & CLI support - #1594

Merged
Shashankss1205 merged 1 commit into
CodeGraphContext:mainfrom
shanmukhdatta:main
Aug 13, 2026
Merged

Fixes #1542: Parameterize relationship query limits, add truncation flags & CLI support#1594
Shashankss1205 merged 1 commit into
CodeGraphContext:mainfrom
shanmukhdatta:main

Conversation

@shanmukhdatta

Copy link
Copy Markdown
Contributor

Fixes #1542

Context & Solution

Issue #1542 flagged that find_callers and other relationship queries silently capped output at 20 results regardless of TOOL_RESULT_LIMITS configuration, and failed to notify callers when results were truncated.

This PR parameterizes the Cypher LIMIT clauses across relationship search queries in code_finder.py, adds truncated (bool) and result_limit (int) metadata to response envelopes, and updates CLI commands to respect configured limits.

Changes Made

  • code_finder.py: Parameterized LIMIT 20 clauses with limit: Optional[int] = None across 8 relationship functions (who_calls_function, what_does_function_call, who_imports_module, find_functions_by_argument, find_functions_by_decorator, who_modifies_variable, find_function_overrides, find_function_call_chain).
  • analyze_code_relationships(): Resolves TOOL_RESULT_LIMITS per query type, queries limit + 1 rows to detect truncation, slices to limit, and adds "truncated" and "result_limit" keys to output envelopes. Appends truncation notices to summary strings.
  • analysis_handlers.py: Forwards "truncated" and "result_limit" flags from envelope dicts to top-level handler responses.
  • cli/main.py: Updated CLI subcommands (analyze callers, analyze calls, analyze chain, analyze overrides, find decorator, find argument) to query with limit + 1 and print truncation warnings when output is capped.
  • tests/unit/tools/test_relationship_tool_limits.py: Added unit tests covering limit enforcement, truncation flags, TOOL_RESULT_LIMITS env overrides, handler forwarding, and untruncated regressions.

Testing & Verification

  • uv run python -m pytest tests/unit/tools/test_relationship_tool_limits.py (4/4 PASSED)
  • uv run python -m pytest tests/unit/tools/ (400 PASSED, 3 SKIPPED)

GSSoC Contributor Notice: Please add gssoc and appropriate level label (level2/level3) to this PR. Thank you!

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@shanmukhdatta is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Shashankss1205 Shashankss1205 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally against the exact reproduction from #1542 (25 distinct callers, KuzuDB backend):

  • default config → 20 results + Total: 20 caller(s) (truncated, 20+ exist)
  • TOOL_RESULT_LIMITS={"find_callers": 50} → all 25 results, no truncation notice

Full unit suite (1117 passed) and integration suite (44 passed) green on a trial-merge onto main. Parameterized LIMIT $limit is consistent with the existing pattern in report_generator.py and java_toolkit.py, so it holds across backends. Thanks for the thorough fix!

@Shashankss1205
Shashankss1205 merged commit 3ec906a into CodeGraphContext:main Aug 13, 2026
1 check failed
@github-project-automation github-project-automation Bot moved this from Backlog tasks to Done in CGC Progress Board Aug 13, 2026
@shanmukhdatta

Copy link
Copy Markdown
Contributor Author

please add the girl script summer of code tag to this to consider for commit of contribution

@Shashankss1205 Shashankss1205 added gssoc:approved GSSoC validation: counts toward scoring level:advanced GSSoC difficulty: 55 pts contributor / 30 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:clean GSSoC quality: x1.2 contributor / +5 mentor type:feature GSSoC type bonus: feature labels Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC validation: counts toward scoring level:advanced GSSoC difficulty: 55 pts contributor / 30 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:clean GSSoC quality: x1.2 contributor / +5 mentor type:feature GSSoC type bonus: feature

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

find_callers silently caps at 20 results; TOOL_RESULT_LIMITS has no effect and no truncated flag is set

2 participants