mirror of
https://github.com/openai/codex.git
synced 2026-09-17 12:23:33 +00:00
Inherit ready step environments when spawning agents (#35895)
## Why With deferred execution, an environment can become ready before a later step spawns a sub-agent. The child must inherit the environment selections available to that step. ## What changed - Use the current step context's environment selections when spawning agents in both multi-agent implementations. - Add coverage that waits for a remote environment to become ready, spawns an agent, and verifies that the child receives both remote and local selections. GitOrigin-RevId: 97c37d541342bbefc9217bf341a19ebdfead2c76
This commit is contained in:
@@ -46,11 +46,12 @@ async fn handle_spawn_agent(
|
||||
) -> Result<SpawnAgentResult, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
turn,
|
||||
step_context,
|
||||
payload,
|
||||
call_id,
|
||||
..
|
||||
} = invocation;
|
||||
let turn = &step_context.turn;
|
||||
let arguments = function_arguments(payload)?;
|
||||
let args: SpawnAgentArgs = parse_arguments(&arguments)?;
|
||||
let role_name = args
|
||||
@@ -70,7 +71,7 @@ async fn handle_spawn_agent(
|
||||
}
|
||||
session
|
||||
.emit_turn_item_started(
|
||||
&turn,
|
||||
turn,
|
||||
&TurnItem::CollabAgentToolCall(CollabAgentToolCallItem {
|
||||
id: call_id.clone(),
|
||||
tool: CollabAgentTool::SpawnAgent,
|
||||
@@ -128,7 +129,7 @@ async fn handle_spawn_agent(
|
||||
fork_mode: args.fork_context.then_some(SpawnAgentForkMode::FullHistory),
|
||||
parent_thread_id: Some(session.thread_id),
|
||||
parent_turn_id: Some(turn.sub_id.clone()),
|
||||
environments: Some(turn.environments.to_selections()),
|
||||
environments: Some(step_context.environments.to_selections()),
|
||||
},
|
||||
))
|
||||
.await
|
||||
@@ -188,7 +189,7 @@ async fn handle_spawn_agent(
|
||||
.unwrap_or_default();
|
||||
session
|
||||
.emit_turn_item_completed(
|
||||
&turn,
|
||||
turn,
|
||||
TurnItem::CollabAgentToolCall(CollabAgentToolCallItem {
|
||||
id: call_id,
|
||||
tool: CollabAgentTool::SpawnAgent,
|
||||
|
||||
@@ -41,12 +41,13 @@ async fn handle_spawn_agent(
|
||||
) -> Result<SpawnAgentResult, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
turn,
|
||||
step_context,
|
||||
payload,
|
||||
call_id,
|
||||
source,
|
||||
..
|
||||
} = invocation;
|
||||
let turn = &step_context.turn;
|
||||
let arguments = function_arguments(payload)?;
|
||||
let args: SpawnAgentArgs = parse_arguments(&arguments)?;
|
||||
let fork_mode = args.fork_mode()?;
|
||||
@@ -126,7 +127,7 @@ async fn handle_spawn_agent(
|
||||
fork_mode,
|
||||
parent_thread_id: Some(session.thread_id),
|
||||
parent_turn_id: Some(turn.sub_id.clone()),
|
||||
environments: Some(turn.environments.to_selections()),
|
||||
environments: Some(step_context.environments.to_selections()),
|
||||
},
|
||||
),
|
||||
)
|
||||
@@ -144,7 +145,7 @@ async fn handle_spawn_agent(
|
||||
.or(spawned_agent.metadata.agent_nickname);
|
||||
emit_sub_agent_activity(
|
||||
&session,
|
||||
&turn,
|
||||
turn,
|
||||
SubAgentActivityItem {
|
||||
id: call_id,
|
||||
agent_thread_id: new_thread_id,
|
||||
|
||||
Reference in New Issue
Block a user