Keep MCP event subscriptions alive after task unloading (#41899)

## Why

Event subscriptions may need to outlive the MCP runtime associated with a task.

## What changed

- Add `McpEventStreamOpener`, which retains the hosted Apps MCP connection settings and opens each event stream with an independent client.
- Keep subscription cancellation tied to account changes and removal of the task's event server, including when cancellation ownership is forwarded across runtime replacement.
- Expose the opener and cancellation forwarding through `McpResourceClient`.

## Testing

Add an HTTP transport test that shuts down the runtime, refreshes credentials for the same account, and verifies that a new event stream connects with the current authorization and receives notifications.

GitOrigin-RevId: e102aa382e63121661ff0567f7523515e459922d
This commit is contained in:
Evan Fannin authored and copyberry committed 2026-08-31 19:18:18 +00:00
1 parent d60560f14e
commit 53691bad98
11 files changed
+520 -15

No files matched your search

+2
View File
@@ -7,6 +7,7 @@ pub use elicitation::ElicitationLifecycle;
pub use elicitation::ElicitationReviewRequest;
pub use elicitation::ElicitationReviewer;
pub use elicitation::ElicitationReviewerHandle;
pub use event_stream::McpEventStreamOpener;
pub use resource_client::McpEventCatalogSnapshot;
pub use resource_client::McpEventDefinition;
pub use resource_client::McpEventNotification;
@@ -102,6 +103,7 @@ mod client_capabilities;
pub(crate) mod codex_apps;
pub(crate) mod connection_manager;
pub(crate) mod elicitation;
mod event_stream;
mod executor_environment_http_client;
pub(crate) mod mcp;
mod openai_docs_source_attribution;