mirror of
https://github.com/openai/codex.git
synced 2026-10-25 18:28:38 +00:00
Consolidate multi-agent v2 communication sends
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user