Expose session sources to MCP contributors (#37167)

## What changed

- Add `session_source()` to `McpServerContributionContext` for thread-scoped MCP resolution.
- Propagate each thread's `SessionSource` through initial setup, per-step resolution, and runtime refreshes.

## Testing

- Verify global contexts omit the source while thread-scoped contexts retain it.
- Verify MCP contributors observe distinct sources for a root thread and its spawned subagent.

GitOrigin-RevId: 23da1509858e023fbd9e2d179034ddc83553f17b
This commit is contained in:
Rasmus Rygaard authored and copyberry committed 2026-08-05 21:45:33 +00:00
1 parent ad6e48ddd3
commit 15ea598c6e
9 files changed
+239 -24

No files matched your search

+3
View File
@@ -16,6 +16,7 @@ pub(super) struct McpDesiredState {
pub(super) auth: Option<CodexAuth>,
pub(super) submit_id: String,
pub(super) originator: String,
pub(super) session_source: SessionSource,
pub(super) environments: TurnEnvironmentSnapshot,
pub(super) windows_sandbox_level: WindowsSandboxLevel,
}
@@ -74,6 +75,7 @@ impl Session {
auth,
submit_id: self.next_internal_sub_id(),
originator: session_configuration.originator.clone(),
session_source: session_configuration.session_source.clone(),
environments,
windows_sandbox_level: session_configuration.windows_sandbox_level,
}
@@ -95,6 +97,7 @@ impl Session {
auth,
submit_id: INITIAL_SUBMIT_ID.to_owned(),
originator: session_configuration.originator.clone(),
session_source: session_configuration.session_source.clone(),
environments: resolved_environments.clone(),
windows_sandbox_level: session_configuration.windows_sandbox_level,
};