-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Redesign lifespan: separate server-scoped and session-scoped lifetimes #2113
Copy link
Copy link
Open
Labels
P1Significant bug affecting many users, highly requested featureSignificant bug affecting many users, highly requested featurebreaking changeWill break existing deployments when updated without changesWill break existing deployments when updated without changesenhancementRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supportedv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
Metadata
Metadata
Assignees
Labels
P1Significant bug affecting many users, highly requested featureSignificant bug affecting many users, highly requested featurebreaking changeWill break existing deployments when updated without changesWill break existing deployments when updated without changesenhancementRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supportedv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
Summary
The current lifespan implementation is tied to sessions/transports rather than having distinct scopes. This causes two P0 bugs (#1300, #1304) and makes the model fundamentally wrong for production use.
Problem
streamable-http, the lifespan does not execute on server startup — it only runs when a client connects and a session is created (Lifespan does not execute on startup streamable-http #1300)stateless_http=True, the lifespan enters and exits for every request because each request spins up a new transport (Lifespan enters and exits for each request when stateless_http=True #1304)Goal
Provide two distinct lifetime scopes:
Both should be accessible from handler context. The current single
lifespanparameter should be replaced or extended to support both scopes.Subsumes
AI Disclaimer