Use runtime authentication for OpenAI MCP and app requests (#59749)

## What changed

- Select fresh authentication for each HTTP operation on eligible OpenAI MCP connections while preserving the connection's credential source and account network policy. Stop redirects when requests carry runtime assertions.
- Pass the owning thread's authentication and runtime context through app discovery, connector metadata, and trusted-access requests. Include the runtime authentication mode in MCP connection and tool-cache identities.
- Give resumed actors analytics clients bound to their own authentication context, and serialize stored-credential reloads with token refresh while preserving host-provided credentials.

## Testing

Add coverage for fresh request assertions, revoked account policies, redirect handling, resumed-actor isolation, and MCP uploads in dual-header and assertion-only modes.

GitOrigin-RevId: f06900a6db61cd6cf53c3aa8075afeec4d5706d9
This commit is contained in:
cooper-oai
2026-11-05 22:03:29 +00:00
committed by copyberry
parent e934edd68c
commit 219ab4043e
51 changed files with 1901 additions and 250 deletions
+10
View File
@@ -368,6 +368,16 @@ impl Session {
self.mcp_runtime_context(&desired.environments, &desired.local_process_cwd);
McpRuntimeInput {
network_policy_metadata: None,
runtime_auth: desired
.config
.features
.enabled(Feature::RuntimeAgentInstances)
.then(|| {
(
Arc::clone(&self.services.runtime_auth),
desired.config.runtime_auth_mode,
)
}),
startup_policy: if matches!(desired.session_source, SessionSource::SubAgent(_)) {
McpStartupPolicy::LazyWhenCached
} else {
+4 -3
View File
@@ -1200,9 +1200,10 @@ async fn required_mcp_servers_for_input(
}));
let connector_slug_counts = if turn_context.apps_enabled() && !mentions.plain_names.is_empty() {
let cached_connectors =
connectors::list_cached_accessible_connectors_from_mcp_tools(&turn_context.config)
.await;
let cached_connectors = connectors::list_cached_accessible_connectors_from_mcp_tools(
&turn_context.config,
sess.services.auth_manager.auth().await.as_ref(),
);
let accessible_connectors = match cached_connectors {
Some(connectors) => connectors,
None => sess