You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: AI Chat Fails Due to Context Window Overflow (Improper Token Handling) #407
The current AI chat system limits conversation context by storing only the last 8 messages, assuming this prevents exceeding the model’s context window. However, this approach does not account for token size variability, where longer messages can significantly increase token count.
As a result, even with fewer messages, the total token size can exceed the model’s limit, causing API failures such as “Context Window Exceeded” errors. This leads to unstable chat behavior and failed responses during extended or detailed conversations.
Steps to Reproduce
Open the AI chat feature
Enter multiple long or detailed messages (e.g., large paragraphs or code blocks)
Continue the conversation beyond a few exchanges
Observe API failure or missing response
Expected Behavior
The chat system should dynamically manage context to stay within token limits
AI responses should consistently generate without errors
Long conversations should be handled gracefully
Actual Behavior
API requests fail with context window exceeded errors
Chat responses stop working after several long messages
No fallback or recovery mechanism is triggered
Activity
Tushar15769 commentedon May 3, 2026
Please assign this issue to me under NSoC'26
Thanks!
madsysharma commentedon May 10, 2026
Hi @devanshi14malhotra , I would like to work on this issue as part of GSSoC 2026.
Tushar15769 commentedon May 10, 2026
I have resolved the issue and raised the PR so whenever you get time please review it and tell your views on the changes @devanshi14malhotra .
Thanks!