Restrict agent roles to bounded configuration overrides (#39299)

## Why

Agent roles should customize a child agent without expanding the authority or changing the provider configuration inherited from its parent session.

## What changed

- Apply only supported role overrides for model behavior, developer instructions, personality, service tier, and capability reductions.
- Preserve parent-owned permissions, model providers, endpoints, MCP servers, notifications, and other unrestricted configuration.
- Keep managed feature requirements effective when a role disables capabilities, and reject symlinked user role files.
- Use the same bounded role application path for both multi-agent implementations and resumed agents.

## Testing

Add coverage for authority preservation, managed feature requirements, symlink rejection, provider inheritance, and provider routing after resume.

GitOrigin-RevId: c528d615b691f9c02bfbc21154d514ea07743010
This commit is contained in:
jif
2026-08-18 22:20:32 +00:00
committed by copyberry
parent 45528c5132
commit 1a6e07a4fe
6 changed files with 332 additions and 209 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
use super::residency::is_v2_resident_session_source;
use super::*;
use crate::agent::role::apply_role_to_config_for_multi_agent_v2;
use crate::agent::role::apply_role_to_config;
use crate::config::PermissionProfileSnapshot;
use crate::context::ContextualUserFragment;
use crate::context::CurrentTimeReminder;
@@ -310,7 +310,7 @@ impl AgentControl {
),
};
apply_role_to_config_for_multi_agent_v2(&mut config, Some(&role_name))
apply_role_to_config(&mut config, Some(&role_name))
.await
.map_err(CodexErr::InvalidRequest)?;
config