Fix unbounded chat history leading to OOM (fixes #447)#492
Fix unbounded chat history leading to OOM (fixes #447)#492atul-upadhyay-7 wants to merge 1 commit into
Conversation
|
@atul-upadhyay-7 is attempting to deploy a commit to the firefistisdead's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
More reviews will be available in 38 minutes and 12 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a configurable cap on per-session chat history and enforces that cap when loading, appending, and persisting sessions to prevent unbounded growth.
Changes:
- Introduce
MAX_CHAT_HISTORY_SIZEenv var and document it in.env.example - Truncate chat history to
MAX_CHAT_HISTORY_SIZEexchanges during session load/save/snapshot and onappend_chat_exchange - Add a unit test for truncation behavior; disable an existing PDF worker test
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| rag-service/main.py | Enforces chat history truncation across load/save/snapshot and when appending new exchanges; adds MAX_CHAT_HISTORY_SIZE config |
| rag-service/test_main.py | Adds truncation test; comments out PDF worker test and removes worker import |
| .env.example | Documents MAX_CHAT_HISTORY_SIZE env var |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes #447
This PR adds a
MAX_CHAT_HISTORY_SIZEconfigurable limit to prevent out-of-memory crashes due to unbounded chat histories. The limit is enforced across the active session memory, background persistence, and on-startup loads to ensure robust and bounded memory usage.