Skip to content

Fix unbounded chat history leading to OOM (fixes #447)#492

Open
atul-upadhyay-7 wants to merge 1 commit into
FireFistisDead:masterfrom
atul-upadhyay-7:fix-chat-history-oom-447
Open

Fix unbounded chat history leading to OOM (fixes #447)#492
atul-upadhyay-7 wants to merge 1 commit into
FireFistisDead:masterfrom
atul-upadhyay-7:fix-chat-history-oom-447

Conversation

@atul-upadhyay-7

Copy link
Copy Markdown

Closes #447

This PR adds a MAX_CHAT_HISTORY_SIZE configurable 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.

Copilot AI review requested due to automatic review settings June 7, 2026 12:50
@vercel

vercel Bot commented Jun 7, 2026

Copy link
Copy Markdown

@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.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@atul-upadhyay-7, we couldn't start this review because you've reached your PR review rate limit.

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 @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 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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 287d339d-8549-4405-bf38-8b50b67b3a0d

📥 Commits

Reviewing files that changed from the base of the PR and between 42ae762 and 6ef0f87.

📒 Files selected for processing (3)
  • .env.example
  • rag-service/main.py
  • rag-service/test_main.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added bug Something isn't working feature A new feature or improvement fix A targeted fix or cleanup rag-service FastAPI / model service work labels Jun 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_SIZE env var and document it in .env.example
  • Truncate chat history to MAX_CHAT_HISTORY_SIZE exchanges during session load/save/snapshot and on append_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.

Comment thread rag-service/main.py
Comment thread rag-service/main.py
Comment thread rag-service/test_main.py
Comment thread .env.example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature A new feature or improvement fix A targeted fix or cleanup rag-service FastAPI / model service work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Chat history grows without bound — memory exhaustion and OOM crash under sustained usage

2 participants