-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add idle session cleanup to prevent unbounded session accumulation #1343
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
base: main
Are you sure you want to change the base?
Add idle session cleanup to prevent unbounded session accumulation #1343
Conversation
Implement automatic cleanup of idle sessions when session count exceeds configurable threshold (default 10k). Sessions inactive for longer than the idle timeout (default 30 minutes) are terminated to free resources. This prevents memory exhaustion from clients that create sessions but never send termination requests.
- Replace untyped lambdas with properly typed async functions - Fix pyright reportUnknownLambdaType errors - Apply ruff formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ddworken for preparing this!
I'd feel more comfortable if we limited the number of open sessions first (and decline further sessions w/ a 503). There's no good way to label long sessions as inactive atm, as there are growing use cases (and spec change proposals) around long running tool calls for instance, so 30 min w/o activity may be perfectly fine / ditching these sessions would be a breaking change.
Also not sure the current changes prevent a crash caused by a very high number of sessions started at once?
Other suggestions:
WDYT? |
Related: #1159 |
Summary
Changes
Testing
This ensures the server remains stable even when clients don't properly close their sessions.