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
fix(server): expose session_idle_timeout via streamable_http_app() and pause reaping during active requests
Closes#2455.
session_idle_timeout existed only on StreamableHTTPSessionManager, so users
of the high-level streamable_http_app() API had to drop down to manual
session-manager wiring to configure idle reaping. Worse, the idle deadline
was only pushed forward when a request *arrived*, so a request still being
processed when the deadline passed could have its session reaped mid-flight.
- Thread session_idle_timeout through Server.streamable_http_app() and
MCPServer.streamable_http_app() into the session manager.
- Track in-flight requests on the transport: mark_request_started() suspends
idle reaping (deadline -> inf) while >=1 request is active;
mark_request_finished() re-arms the deadline only when the last concurrent
request completes, and is a no-op when no timeout is configured.
- Wrap both stateful handle_request() call sites in start/finished so an
active request is never counted as idle.
- Move task_status.started() to after idle_scope is attached so the first
request cannot race ahead of the scope it needs to suspend.
Verification: 7 new tests (app forwarding + default None, transport
suspend/resume across overlapping requests, no-timeout no-op, counter
underflow guard); 249 streamable/idle/session tests pass; existing
test_idle_session_is_reaped still green. ruff + pyright clean.
0 commit comments