Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Context aware filtering with research_with_chunking method (issue #647) #915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
devtcu wants to merge 1 commit into LearningCircuit:dev
base: dev
Choose a base branch
Loading
from devtcu:feature/context-window-chunking

Conversation

Copy link
Collaborator

@devtcu devtcu commented Oct 7, 2025

Adds research_with_chunking() method to LDRClient which thenautomatically limits sources when too many are found, hopefully preventing context window crashes..

  • Limits to top 10 sources by default (configurable)
  • Only applies chunking when needed
  • Shows when chunking was used
  • Drop-in replacement for quick_research()

@Copilot Copilot AI review requested due to automatic review settings October 7, 2025 23:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new research_with_chunking() method to the LDRClient class to prevent context window crashes by automatically limiting the number of sources processed when research returns too many results.

  • Adds research_with_chunking() method that acts as a drop-in replacement for quick_research()
  • Implements automatic source limiting to top 10 sources (configurable) when needed
  • Provides feedback when chunking is applied through result metadata

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

self, query: str, max_chunk_size: int = 10, **kwargs
) -> Dict[str, Any]:
"""
Trying detect situations in which context will be a problem, and automatically break the operation up into multiple separate filtering operation
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Fixed grammatical errors in the docstring.

Suggested change
Tryingdetect situations in which context willbe aproblem, and automatically break the operation upinto multiple separate filtering operation
Attemptstodetect situations in which thecontext windowwouldbe exceeded, and automatically breaks the operation into multiple separate filtering operations.

Copilot uses AI. Check for mistakes.

if not self.logged_in:
raise RuntimeError("Not logged in. Call login() first.")

# lets get initial results
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Fixed capitalization and apostrophe in comment.

Suggested change
# lets get initial results
# Let's get initial results

Copilot uses AI. Check for mistakes.


sources = result.get("sources", [])

# if there too many sources, keep only the best ones..
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Fixed grammatical error in comment.

Suggested change
# if there too many sources, keep only the best ones..
# if there are too many sources, keep only the best ones.

Copilot uses AI. Check for mistakes.

Comment on lines +377 to +379
def research_with_chunking(
self, query: str, max_chunk_size: int = 10, **kwargs
) -> Dict[str, Any]:
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

The method name and parameter 'max_chunk_size' are misleading. This method doesn't actually chunk sources into multiple requests, it simply truncates to the top N sources. Consider renaming to 'research_with_limit' and the parameter to 'max_sources' for clarity.

Copilot uses AI. Check for mistakes.

@devtcu devtcu changed the title (削除) Fix context window crashes with research_with_chunking method (fixes #647) (削除ここまで) (追記) Fix context window crashes with research_with_chunking method (issue #647) (追記ここまで) Oct 7, 2025
@devtcu devtcu changed the title (削除) Fix context window crashes with research_with_chunking method (issue #647) (削除ここまで) (追記) Context aware filtering with research_with_chunking method (issue #647) (追記ここまで) Oct 7, 2025
@devtcu devtcu linked an issue Oct 7, 2025 that may be closed by this pull request
Copy link
Collaborator

@djpetti djpetti left a comment

Choose a reason for hiding this comment

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

The overall idea is reasonable, but I don't see how the provided code actually solves the problem it's purporting to solve. AFAIK, it runs a normal research and then limits the sources after the fact. I don't see how that will help with context window issues.

As a side note, the proper way to deal with this is probably to modify CrossEngineFilter to filter the sources in chunks instead of all at once. @devtcu You're welcome to attempt that change if you want 😄. I can help you if you get stuck!

@LearningCircuit LearningCircuit added the discussion Topics that need discussion label Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

@djpetti djpetti djpetti requested changes

@LearningCircuit LearningCircuit Awaiting requested review from LearningCircuit LearningCircuit is a code owner

@HashedViking HashedViking Awaiting requested review from HashedViking HashedViking is a code owner

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

discussion Topics that need discussion

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Context-Aware Filtering

AltStyle によって変換されたページ (->オリジナル) /