Skip to content

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

Open
shanmukhdatta wants to merge 1 commit into
CodeGraphContext:mainfrom
shanmukhdatta:main
Open

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

Conversation

@shanmukhdatta

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog tasks

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

1 participant