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

Fix: Improve iterative refinement performance and reduce context explosion #874

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

Draft
LearningCircuit wants to merge 2 commits into dev
base: dev
Choose a base branch
Loading
from fix/iterative-refinement-performance

Conversation

Copy link
Owner

@LearningCircuit LearningCircuit commented Sep 25, 2025

Summary

This PR fixes critical performance issues in the iterative refinement strategy that were causing:

  • Context explosion with unbounded LLM evaluation tokens
  • Query drift where refinements would diverge from the original topic
  • Excessive token usage and slow processing

Changes

  • Set max_evaluation_tokens default to 2000 (was None) to prevent unbounded context growth
  • Refactored _evaluate_with_llm to use structured findings list instead of parsing formatted text
  • Modified to pass only recent refinement findings to LLM instead of all accumulated context
  • Constrained refinement prompts to stay focused on original query

Testing

Tested with query "What to do against stress?" and observed:

  • Refinement queries now stay on topic (no more drift to unrelated company verifications)
  • Faster processing with reduced context
  • Confidence progression improved from erratic (63%→78%→60%) to more stable

Further Work Needed

While this PR addresses the immediate performance issues, additional improvements should be considered:

  • Search relevance: The search still returns some irrelevant sources that need better filtering
  • Confidence threshold tuning: Current threshold of 0.95 may be too high, causing unnecessary refinements
  • Duplicate detection: Add similarity checking to prevent redundant refinements
  • Completeness detection: Improve the evaluation logic to better detect when sufficient information has been gathered

Test Results

Before: Queries drifted from "stress reduction" to "verify 13 companies implementing mental health programs"
After: Queries stay focused - "provide evidence-based stress reduction techniques with mechanisms and actionable steps"

...osion
- Set max_evaluation_tokens default to 2000 (was None) to prevent unbounded context
- Use structured findings list instead of formatted text in _evaluate_with_llm
- Pass only recent refinement findings to LLM instead of all accumulated context
- Constrain refinement prompts to stay focused on original query
This fixes:
- Context explosion causing slow processing and high token costs
- Query drift where refinements diverge from original topic
- Excessive LLM context leading to degraded performance
@Copilot Copilot AI review requested due to automatic review settings September 25, 2025 21:14
Copy link
Owner Author

@djpetti still draft PR (sorry)

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Repository owner deleted a comment from github-actions bot Sep 26, 2025
Repository owner deleted a comment from claude bot Sep 26, 2025
Base automatically changed from fix/subscriptions-css-classes to dev September 28, 2025 18:33
@LearningCircuit LearningCircuit added the dev-bugfix Bug fixes for issues found in dev branch label Oct 3, 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

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

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

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

dev-bugfix Bug fixes for issues found in dev branch

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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