mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Decouple session isolation from subagent attribution (#44521)
## Why Session isolation relied on Guardian source attribution. An explicit policy lets callers control inherited capabilities independently of how a session is attributed. ## What changed - Add `SessionIsolation` with default `Inherit` and opt-in `Isolated` modes, captured at session startup through `ExtensionDataInit`. - Use the policy to control inherited instructions, extensions, execution rules, and MCP resources. Isolated sessions retain managed execution rules and omit executor-discovered MCP servers. - Explicitly isolate Guardian reviewers while preserving source-based fallback for older callers and saved reviewers. ## Testing Extend delegate tests to cover isolation independently of attribution, update execution-policy coverage to supply the explicit policy, and assert that managed reviewers do not inherit the parent's configured MCP tools. GitOrigin-RevId: f0ab42fa2f0237860ec661e72693ab191216afbf
This commit is contained in:
1 parent
9688359977
commit
ed6dde9fda
14 files changed
+83
-18
No files matched your search
@@ -202,6 +202,7 @@ async fn run_codex_thread_interactive_respects_pre_cancelled_spawn() {
|
||||
parent_environments,
|
||||
cancel_token,
|
||||
SubAgentSource::Review,
|
||||
codex_extension_api::SessionIsolation::Inherit,
|
||||
/*initial_history*/ None,
|
||||
crate::session::GitEnrichmentPolicy::Fresh,
|
||||
codex_sandboxing::WindowsSandboxProxySettingsMode::Reconcile,
|
||||
@@ -217,7 +218,7 @@ async fn run_codex_thread_interactive_respects_pre_cancelled_spawn() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn guardian_delegates_do_not_inherit_parent_extensions() {
|
||||
async fn delegate_isolation_does_not_depend_on_attribution() {
|
||||
let (mut parent_session, parent_ctx, _rx_events) =
|
||||
crate::session::tests::make_session_and_context_with_rx().await;
|
||||
let thread_starts = Arc::new(AtomicUsize::new(0));
|
||||
@@ -229,13 +230,25 @@ async fn guardian_delegates_do_not_inherit_parent_extensions() {
|
||||
.services
|
||||
.extensions = Arc::new(extensions.build());
|
||||
|
||||
for (subagent_source, expected_thread_starts, expected_thread_source) in [
|
||||
for (subagent_source, isolation, expected_thread_starts, expected_thread_source) in [
|
||||
(
|
||||
SubAgentSource::Other(crate::guardian::GUARDIAN_REVIEWER_NAME.to_string()),
|
||||
codex_extension_api::SessionIsolation::Isolated,
|
||||
0,
|
||||
ThreadSource::GuardianReview,
|
||||
),
|
||||
(SubAgentSource::Review, 1, ThreadSource::Subagent),
|
||||
(
|
||||
SubAgentSource::Review,
|
||||
codex_extension_api::SessionIsolation::Isolated,
|
||||
0,
|
||||
ThreadSource::Subagent,
|
||||
),
|
||||
(
|
||||
SubAgentSource::Review,
|
||||
codex_extension_api::SessionIsolation::Inherit,
|
||||
1,
|
||||
ThreadSource::Subagent,
|
||||
),
|
||||
] {
|
||||
let mut config = parent_ctx.config.as_ref().clone();
|
||||
config.permissions.approval_policy = Constrained::allow_only(AskForApproval::Never);
|
||||
@@ -248,6 +261,7 @@ async fn guardian_delegates_do_not_inherit_parent_extensions() {
|
||||
parent_ctx.environments.clone(),
|
||||
CancellationToken::new(),
|
||||
subagent_source,
|
||||
isolation,
|
||||
/*initial_history*/ None,
|
||||
crate::session::GitEnrichmentPolicy::Fresh,
|
||||
codex_sandboxing::WindowsSandboxProxySettingsMode::Reconcile,
|
||||
@@ -291,6 +305,7 @@ async fn run_codex_thread_interactive_rejects_approval_policy_that_can_prompt()
|
||||
parent_environments,
|
||||
CancellationToken::new(),
|
||||
SubAgentSource::Review,
|
||||
codex_extension_api::SessionIsolation::Inherit,
|
||||
/*initial_history*/ None,
|
||||
crate::session::GitEnrichmentPolicy::Fresh,
|
||||
codex_sandboxing::WindowsSandboxProxySettingsMode::Reconcile,
|
||||
|
||||
Reference in new issue
Block a user