Skip to content

Fix: _process_result always returns truncated result regardless of size#868

Open
manvibuilds wants to merge 1 commit into
potpie-ai:mainfrom
manvibuilds:fix/process-result-return
Open

Fix: _process_result always returns truncated result regardless of size#868
manvibuilds wants to merge 1 commit into
potpie-ai:mainfrom
manvibuilds:fix/process-result-return

Conversation

@manvibuilds

Copy link
Copy Markdown

Fixes #724

Problem

_process_result in GetCodeFromNodeIdTool was always returning
truncated_result even for results under 80,000 characters. This meant
AI agents were receiving unnecessarily truncated responses instead of
the full result.

Fix

Return the original result when it's under the 80,000 character limit,
and only return truncated_result when truncation is actually needed.

Changes

  • legacy/app/modules/intelligence/tools/kg_based_tools/get_code_from_node_id_tool.py
    • Added return result for the normal (under size limit) case
    • Moved return truncated_result inside the if block where it belongs

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: a1c69b93-64dd-41e4-b658-199321e57578

📥 Commits

Reviewing files that changed from the base of the PR and between 3cb6fca and d4d46f7.

📒 Files selected for processing (1)
  • legacy/app/modules/intelligence/tools/kg_based_tools/get_code_from_node_id_tool.py

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where code retrieval results were being unnecessarily truncated. The system now returns complete results when they don't exceed size limits, and only applies truncation when necessary.

Walkthrough

The pull request fixes a critical bug in the _process_result method of GetCodeFromNodeIdTool. The method was missing a return statement, causing it to implicitly return None for results under 80,000 characters. The fix ensures the full result is returned when within size limits, and only the truncated version is returned when exceeding the threshold.

Changes

Result Processing Fix

Layer / File(s) Summary
Truncation return logic fix
legacy/app/modules/intelligence/tools/kg_based_tools/get_code_from_node_id_tool.py
The _process_result method now correctly returns truncated_result only when len(str(result)) > 80000, and returns the full result otherwise, fixing the implicit None return for normal-sized responses.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: correcting _process_result to return the correct value based on size, rather than always returning the truncated result.
Description check ✅ Passed The description clearly explains the problem, fix, and specific changes made, directly relating to the code modifications in the pull request.
Linked Issues check ✅ Passed The pull request fully addresses issue #724 by implementing the suggested fix: returning the original result when under the 80,000 character limit and only returning truncated_result when necessary.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the _process_result bug described in issue #724; no out-of-scope modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@manvibuilds

Copy link
Copy Markdown
Author

The failing tests aren't related to this fix they're all throwing FileNotFoundError for a missing linear/issue_detail.json test data file, which seems like a pre-existing issue in the repo. My change only touches the legacy tool file. which passes all the test.

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.

[Bug] Critical: _process_result always returns None for normal-sized results — silently breaks all code retrieval

1 participant