Add configured thread environment inheritance for subagents (#55327)

## Why

Temporary environment attachments for a parent's turn should not become a child's persistent environment configuration or survive child eviction.

## What changed

- Add the default-disabled `subagent_thread_environments` feature flag. When enabled, subagents inherit configured thread environments captured with the spawning step instead of active turn selections.
- Track configured bindings separately from turn attachments, preserving pending configuration ownership when turn selections change.
- Retain configured bindings across child eviction and reload, excluding temporary attachments. Preserve the child's workspace when the parent switches workspaces, while enforcing current roots and permissions when the parent still configures the same workspace.

## Testing

Extend coverage for both multi-agent versions, forked children, empty configured environments, pending configuration, and legacy inheritance. Add eviction and reload cases covering temporary attachments, workspace changes, deferred executor startup, and permission validation.

GitOrigin-RevId: 4533645503d5f863a9ccc064386ed7ca169d98b7
This commit is contained in:
jif
2026-10-19 17:16:22 +00:00
committed by copyberry
parent 8dd6099e26
commit d70c2c2cdf
23 changed files with 667 additions and 132 deletions
+1 -1
View File
@@ -152,7 +152,7 @@ pub(crate) async fn spawn(
parent_turn_id: Some(turn.sub_id.clone()),
root_turn_id: turn.turn_metadata_state.root_turn_id(),
turn_trigger: turn.turn_metadata_state.current_turn_trigger(),
environments: Some(step_context.environments.clone()),
environments: Some(step_context.inherited_environments.clone()),
disabled_plugin_ids: Some(turn.disabled_plugin_ids.clone()),
multi_agent_v2_usage_hints,
cyber_access_program: turn.cyber_access_program,