Consolidate multi-agent v2 communication sends

This commit is contained in:
Michael Bolin
2026-07-01 13:53:22 -07:00
parent d059658ad1
commit b1d06b8c05
2 changed files with 39 additions and 4 deletions
+21 -2
View File
@@ -183,12 +183,31 @@ impl AgentControl {
agent_id: ThreadId,
communication: InterAgentCommunication,
) -> CodexResult<String> {
let last_task_message = last_task_message_from_communication(&communication);
let state = self.upgrade()?;
let op = Op::InterAgentCommunication { communication };
self.ensure_execution_capacity_for_op(agent_id, &op).await?;
let Op::InterAgentCommunication { communication } = op else {
unreachable!("constructed as an inter-agent communication operation");
};
self.send_inter_agent_communication_after_capacity_check(agent_id, &state, communication)
.await
}
async fn send_inter_agent_communication_after_capacity_check(
&self,
agent_id: ThreadId,
state: &Arc<ThreadManagerState>,
communication: InterAgentCommunication,
) -> CodexResult<String> {
let last_task_message = last_task_message_from_communication(&communication);
let result = self
.handle_thread_request_result(agent_id, &state, state.send_op(agent_id, op).await)
.handle_thread_request_result(
agent_id,
state,
state
.send_op(agent_id, Op::InterAgentCommunication { communication })
.await,
)
.await;
if result.is_ok() {
match last_task_message {
+18 -2
View File
@@ -356,8 +356,24 @@ impl AgentControl {
)
.await;
self.send_input_after_capacity_check(new_thread.thread_id, &state, initial_operation)
.await?;
match (multi_agent_version, initial_operation) {
(MultiAgentVersion::V2, Op::InterAgentCommunication { communication }) => {
self.send_inter_agent_communication_after_capacity_check(
new_thread.thread_id,
&state,
communication,
)
.await?;
}
(_, initial_operation) => {
self.send_input_after_capacity_check(
new_thread.thread_id,
&state,
initial_operation,
)
.await?;
}
}
if multi_agent_version != MultiAgentVersion::V2 {
let child_reference = agent_metadata
.agent_path