Skip to content

LCORE-1333: Define max chunks to retrieve for RAG#1765

Open
are-ces wants to merge 2 commits into
lightspeed-core:mainfrom
are-ces:lcore-1333
Open

LCORE-1333: Define max chunks to retrieve for RAG#1765
are-ces wants to merge 2 commits into
lightspeed-core:mainfrom
are-ces:lcore-1333

Conversation

@are-ces
Copy link
Copy Markdown
Contributor

@are-ces are-ces commented May 19, 2026

Description

Add RAG_CONTENT_LIMIT constant (default: 10) to constants.py that caps the final merged BYOK + OKP inline RAG output from build_rag_context. Per-source constants (BYOK_RAG_MAX_CHUNKS, OKP_RAG_MAX_CHUNKS) remain as fetch hints for the reranking pool — users can increase them to feed more candidates to the cross-encoder reranker before the final cap is applied.

Tool RAG keeps its own TOOL_RAG_MAX_CHUNKS constant independently so that users can set different max chunk limits for tool RAG and inline RAG separately.

Also adds test_responses_byok_integration.py — the /responses endpoint had no BYOK RAG integration tests. The new file covers inline RAG, tool RAG, combined RAG, score multiplier, chunk capping, and RAG_CONTENT_LIMIT enforcement, matching the existing test coverage for /query and /streaming_query.

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

  • Assisted-by: Claude
  • Generated by: Claude Opus 4.6

Related Tickets & Documents

  • Closes LCORE-1333

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • 2284 unit tests pass, 214 integration tests pass
  • uv run make verify passes all linters
  • New tests verify RAG_CONTENT_LIMIT caps inline RAG chunks when set below per-source constants (patched to 3, feeds 10 chunks, asserts cap at 3)
  • Existing capping tests updated to assert against RAG_CONTENT_LIMIT

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

Warning

Rate limit exceeded

@are-ces has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 39 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e1261bf5-cb6c-4d5e-a909-aab3db4f8fa7

📥 Commits

Reviewing files that changed from the base of the PR and between 559753d and a18cf4c.

📒 Files selected for processing (7)
  • docs/byok_guide.md
  • docs/rag_guide.md
  • src/constants.py
  • src/utils/vector_search.py
  • tests/integration/endpoints/test_query_byok_integration.py
  • tests/integration/endpoints/test_responses_byok_integration.py
  • tests/integration/endpoints/test_streaming_query_byok_integration.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

@are-ces are-ces force-pushed the lcore-1333 branch 3 times, most recently from 16cbaa5 to 6fbe0e9 Compare May 19, 2026 07:33
are-ces and others added 2 commits May 19, 2026 09:36
Add test_responses_byok_integration.py with integration tests covering
inline RAG, tool RAG, combined RAG, score multiplier, chunk capping,
and RAG_CONTENT_LIMIT enforcement for the /responses endpoint.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add RAG_CONTENT_LIMIT constant (default: 10) that caps the final merged
BYOK + OKP output from build_rag_context. Per-source constants remain as
fetch hints for the reranking pool. Tool RAG is unaffected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant