mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
Resume idle V3 workers with send_message (#64750)
## What changed In multi-agent V3, `send_message` starts a new turn in an idle worker's existing conversation, including after eviction. The worker receives the input as a `MESSAGE`. Sends to `/root` still follow its wake policy. Remove `followup_task` from the V3 tool set and select role instructions that match the agent tree's version. ## Testing Cover delivery to active workers at the concurrency limit, retrying an idle worker once a slot opens, and resuming workers after eviction or session restore. GitOrigin-RevId: 3b0e55f150784896aa6e0dfa926bc490bdd2627d
This commit is contained in:
@@ -273,12 +273,11 @@ impl LocalAgentControl {
|
||||
) -> CodexResult<String> {
|
||||
let terminal_result = context.kind == AgentCommunicationKind::Result;
|
||||
let publish = || {
|
||||
MessageDelivery::publish(
|
||||
context.sender_thread_id,
|
||||
context.source_tool_call_id.clone(),
|
||||
Some(MessageDelivery::publish(
|
||||
&context,
|
||||
state.extensions.message_lifecycle_contributors(),
|
||||
terminal_result.then_some(&self.runtime.unconfirmed_results),
|
||||
)
|
||||
))
|
||||
};
|
||||
let log_content = crate::agent_communication::send_log_content(&communication);
|
||||
let (thread, guard) = {
|
||||
|
||||
@@ -155,11 +155,12 @@ impl AgentControl for LocalAgentControl {
|
||||
"target agent is missing an agent_path".to_string(),
|
||||
)
|
||||
})?;
|
||||
let communication = message.into_communication(author, receiver_path, mode);
|
||||
// Cold-restored children still reload lazily on any message. Only
|
||||
// locally evicted recipients can retain mail without reloading.
|
||||
// Loaded recipients go straight to delivery, which rejects sends
|
||||
// racing an in-progress eviction when it acquires the residency pin.
|
||||
let _residency_pin = if mode == MessageDeliveryMode::TriggerTurn
|
||||
let _residency_pin = if communication.trigger_turn
|
||||
|| (self.runtime.upgrade()?.get_thread(target).await.is_err()
|
||||
&& self.runtime.registry.evicted_environments(target).is_none())
|
||||
{
|
||||
@@ -168,10 +169,11 @@ impl AgentControl for LocalAgentControl {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let communication = message.into_communication(author, receiver_path, mode);
|
||||
if !communication.trigger_turn {
|
||||
start_options.parent_turn_id = None;
|
||||
}
|
||||
let kind = match mode {
|
||||
MessageDeliveryMode::QueueOnly => {
|
||||
start_options.parent_turn_id = None;
|
||||
MessageDeliveryMode::QueueOnly | MessageDeliveryMode::WakeWorker => {
|
||||
AgentCommunicationKind::Message
|
||||
}
|
||||
MessageDeliveryMode::TriggerTurn => AgentCommunicationKind::Followup,
|
||||
|
||||
@@ -15,7 +15,13 @@ impl AgentMessage {
|
||||
recipient: AgentPath,
|
||||
mode: MessageDeliveryMode,
|
||||
) -> InterAgentCommunication {
|
||||
let trigger_turn = mode == MessageDeliveryMode::TriggerTurn;
|
||||
let (trigger_turn, message_type) = match mode {
|
||||
MessageDeliveryMode::QueueOnly => (false, InterAgentMessageType::Message),
|
||||
MessageDeliveryMode::WakeWorker => {
|
||||
(!recipient.is_root(), InterAgentMessageType::Message)
|
||||
}
|
||||
MessageDeliveryMode::TriggerTurn => (true, InterAgentMessageType::NewTask),
|
||||
};
|
||||
match self {
|
||||
Self::Encrypted(message) => InterAgentCommunication::new_encrypted(
|
||||
author,
|
||||
@@ -25,10 +31,6 @@ impl AgentMessage {
|
||||
trigger_turn,
|
||||
),
|
||||
Self::Plaintext(message) => {
|
||||
let message_type = match mode {
|
||||
MessageDeliveryMode::QueueOnly => InterAgentMessageType::Message,
|
||||
MessageDeliveryMode::TriggerTurn => InterAgentMessageType::NewTask,
|
||||
};
|
||||
let content = InterAgentMessage::new(
|
||||
message_type,
|
||||
recipient.clone(),
|
||||
|
||||
@@ -3316,6 +3316,7 @@ async fn spawn_agent_fork_strips_parent_usage_hints_from_compacted_history() {
|
||||
let turn_context = parent_thread.session.new_default_turn().await;
|
||||
let parent_spawn_call_id = "spawn-call-compacted-usage-hints".to_string();
|
||||
let catalog_role = |base: &str| MultiAgentRoleInstructions::Composed {
|
||||
version: codex_protocol::protocol::MultiAgentVersion::V2,
|
||||
base: base.to_string(),
|
||||
omit_update_plan_instructions: false,
|
||||
max_concurrency: 2,
|
||||
@@ -4506,12 +4507,10 @@ fn terminal_result_writes_require_confirmation_after_the_parent_claims_mail() {
|
||||
let count = Arc::new(std::sync::atomic::AtomicUsize::default());
|
||||
let publish = || {
|
||||
MessageDelivery::publish(
|
||||
ThreadId::new(),
|
||||
/*source_tool_call_id*/ None,
|
||||
&AgentCommunicationContext::new(AgentCommunicationKind::Result, ThreadId::new()),
|
||||
&[],
|
||||
Some(&count),
|
||||
)
|
||||
.unwrap()
|
||||
};
|
||||
let parent = ThreadId::new();
|
||||
drop(publish().consumed(parent));
|
||||
|
||||
@@ -27,7 +27,7 @@ use codex_history::CodexHarnessMetadata;
|
||||
use codex_history::InitialHistory;
|
||||
use codex_history::ResponseItemEnvelope;
|
||||
use codex_history::RolloutItem;
|
||||
use codex_prompts::ResolvedModelMessages;
|
||||
use codex_prompts::ResolvedMultiAgentMessages;
|
||||
use codex_protocol::SessionId;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::error::CodexErr;
|
||||
@@ -420,7 +420,7 @@ pub(super) async fn prepare_forked_history(
|
||||
let parent_config = parent_thread.session.get_config().await;
|
||||
let parent_usage_hints = resolve_usage_hints(
|
||||
&parent_config.multi_agent_v2,
|
||||
ResolvedModelMessages::bundled().multi_agent(),
|
||||
ResolvedMultiAgentMessages::for_roles(multi_agent_version, /*model*/ None),
|
||||
!parent_config.update_plan_enabled,
|
||||
);
|
||||
[parent_usage_hints.root, parent_usage_hints.subagent]
|
||||
@@ -566,7 +566,7 @@ pub(super) async fn prepare_forked_history(
|
||||
.unwrap_or_else(|| {
|
||||
resolve_usage_hints(
|
||||
&config.multi_agent_v2,
|
||||
ResolvedModelMessages::bundled().multi_agent(),
|
||||
ResolvedMultiAgentMessages::for_roles(multi_agent_version, /*model*/ None),
|
||||
!config.update_plan_enabled,
|
||||
)
|
||||
.subagent
|
||||
|
||||
@@ -74,6 +74,8 @@ pub struct ResolvedMultiAgentV2UsageHints {
|
||||
pub enum MessageDeliveryMode {
|
||||
/// Deliver to the mailbox without starting an idle agent.
|
||||
QueueOnly,
|
||||
/// Send an ordinary message, starting a turn for an idle worker.
|
||||
WakeWorker,
|
||||
/// Deliver to the active turn or start work if the agent is idle.
|
||||
TriggerTurn,
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use codex_extension_api::ExtensionData;
|
||||
use codex_extension_api::MessageLifecycleContributor;
|
||||
use codex_extension_api::MessageLifecycleInput;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::protocol::InterAgentCommunication;
|
||||
use codex_tool_call_id::ToolCallId;
|
||||
use serde::Deserialize;
|
||||
@@ -147,6 +148,18 @@ impl PendingAgentMessage {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn to_model_input_item(&self) -> ResponseItem {
|
||||
if self
|
||||
.delivery
|
||||
.as_ref()
|
||||
.is_some_and(|delivery| delivery.kind == AgentCommunicationKind::Message)
|
||||
{
|
||||
self.communication.to_model_input_item_as_message()
|
||||
} else {
|
||||
self.communication.to_model_input_item()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_terminal_result(&self) -> bool {
|
||||
self.delivery
|
||||
.as_ref()
|
||||
@@ -178,25 +191,27 @@ struct MessagePublication {
|
||||
/// Clones follow one logical delivery through queues and share its consumption state.
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct MessageDelivery {
|
||||
kind: AgentCommunicationKind,
|
||||
pub(crate) source_tool_call_id: Option<ToolCallId>,
|
||||
publication: Option<Arc<Mutex<Option<MessagePublication>>>>,
|
||||
}
|
||||
|
||||
impl MessageDelivery {
|
||||
pub(crate) fn publish(
|
||||
sender: ThreadId,
|
||||
source_tool_call_id: Option<ToolCallId>,
|
||||
context: &AgentCommunicationContext,
|
||||
observers: &[Arc<dyn MessageLifecycleContributor>],
|
||||
unconfirmed_results: Option<&Arc<AtomicUsize>>,
|
||||
) -> Option<Self> {
|
||||
) -> Self {
|
||||
let mut delivery = Self {
|
||||
kind: context.kind,
|
||||
source_tool_call_id: context.source_tool_call_id.clone(),
|
||||
publication: None,
|
||||
};
|
||||
if observers.is_empty() && unconfirmed_results.is_none() {
|
||||
return source_tool_call_id.map(|id| Self {
|
||||
source_tool_call_id: Some(id),
|
||||
publication: None,
|
||||
});
|
||||
return delivery;
|
||||
}
|
||||
let input = MessageLifecycleInput {
|
||||
sender,
|
||||
sender: context.sender_thread_id,
|
||||
data: ExtensionData::new(uuid::Uuid::now_v7().to_string()),
|
||||
};
|
||||
for observer in observers {
|
||||
@@ -211,10 +226,8 @@ impl MessageDelivery {
|
||||
observers: observers.into(),
|
||||
result_write,
|
||||
};
|
||||
Some(Self {
|
||||
source_tool_call_id,
|
||||
publication: Some(Arc::new(Mutex::new(Some(publication)))),
|
||||
})
|
||||
delivery.publication = Some(Arc::new(Mutex::new(Some(publication))));
|
||||
delivery
|
||||
}
|
||||
|
||||
pub(crate) fn awaits_result_write(&self) -> bool {
|
||||
|
||||
@@ -101,6 +101,7 @@ fn unchanged_mode_is_reemitted_after_usage_hint_migration() {
|
||||
#[test]
|
||||
fn catalog_role_updates_remain_separate_from_active_mode() {
|
||||
let catalog_role = |base: &str| MultiAgentRoleInstructions::Composed {
|
||||
version: codex_protocol::protocol::MultiAgentVersion::V2,
|
||||
base: base.to_string(),
|
||||
omit_update_plan_instructions: false,
|
||||
max_concurrency: 2,
|
||||
|
||||
@@ -409,7 +409,6 @@ use codex_protocol::protocol::DeprecationNoticeEvent;
|
||||
use codex_protocol::protocol::Event;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use codex_protocol::protocol::ExecApprovalRequestEvent;
|
||||
use codex_protocol::protocol::InterAgentCommunication;
|
||||
use codex_protocol::protocol::ModelRerouteEvent;
|
||||
use codex_protocol::protocol::ModelRerouteReason;
|
||||
use codex_protocol::protocol::ModelVerification;
|
||||
@@ -4964,7 +4963,7 @@ impl Session {
|
||||
|
||||
/// Builds the same history item whether the recipient is live or has been evicted.
|
||||
pub(crate) fn inter_agent_history_item(
|
||||
communication: &InterAgentCommunication,
|
||||
communication: &crate::PendingAgentMessage,
|
||||
config: &Config,
|
||||
) -> ResponseItem {
|
||||
let mut response_item = communication.to_model_input_item();
|
||||
|
||||
@@ -18,8 +18,10 @@ pub(super) fn usage_hint_text(step_context: &StepContext) -> Option<MultiAgentRo
|
||||
return None;
|
||||
}
|
||||
|
||||
let multi_agent_messages =
|
||||
ResolvedModelMessages::from_model(&step_context.settings.model_info).multi_agent();
|
||||
let multi_agent_messages = ResolvedMultiAgentMessages::for_roles(
|
||||
turn_context.multi_agent_version,
|
||||
Some(&step_context.settings.model_info),
|
||||
);
|
||||
let snapshot = resolve_usage_hints(
|
||||
&turn_context.config.multi_agent_v2,
|
||||
multi_agent_messages,
|
||||
@@ -59,6 +61,7 @@ pub(crate) fn resolve_usage_hints(
|
||||
));
|
||||
}
|
||||
Some(MultiAgentRoleInstructions::Composed {
|
||||
version: multi_agent_messages.role_version,
|
||||
base: base.to_owned(),
|
||||
omit_update_plan_instructions,
|
||||
max_concurrency: config.max_concurrent_threads_per_session,
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::config::Config;
|
||||
use crate::session::multi_agents::resolve_usage_hints;
|
||||
use crate::session::session::Session;
|
||||
use crate::session::step_context::StepContext;
|
||||
use codex_prompts::ResolvedModelMessages;
|
||||
use codex_prompts::ResolvedMultiAgentMessages;
|
||||
use codex_protocol::AgentPath;
|
||||
use codex_protocol::error::CodexErr;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
@@ -199,10 +199,10 @@ pub(crate) async fn prepare(
|
||||
),
|
||||
_ => None,
|
||||
};
|
||||
let child_multi_agent_messages = ResolvedModelMessages::from_model(
|
||||
child_model_info.as_ref().unwrap_or(turn.model_info()),
|
||||
)
|
||||
.multi_agent();
|
||||
let child_multi_agent_messages = ResolvedMultiAgentMessages::for_roles(
|
||||
turn.multi_agent_version,
|
||||
Some(child_model_info.as_ref().unwrap_or(turn.model_info())),
|
||||
);
|
||||
Some(resolve_usage_hints(
|
||||
&config.multi_agent_v2,
|
||||
child_multi_agent_messages,
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
//! Shared argument parsing and dispatch for the v2 agent messaging tools.
|
||||
//!
|
||||
//! `send_message` and `followup_task` share the same submission path and differ only in whether the
|
||||
//! resulting `InterAgentCommunication` should wake the target immediately.
|
||||
//! Shared argument parsing and dispatch for native V2 and V3 agent messages.
|
||||
|
||||
use super::analytics::ToolCallAnalytics;
|
||||
use super::*;
|
||||
@@ -75,7 +72,7 @@ pub(super) async fn handle_message_string_tool(
|
||||
.then(|| call_id.clone()),
|
||||
},
|
||||
start_options: TurnStartOptions {
|
||||
parent_turn_id: (mode == MessageDeliveryMode::TriggerTurn)
|
||||
parent_turn_id: (mode != MessageDeliveryMode::QueueOnly)
|
||||
.then(|| turn.sub_id.clone()),
|
||||
root_turn_id: turn.turn_metadata_state.root_turn_id(),
|
||||
turn_trigger: turn.turn_metadata_state.current_turn_trigger(),
|
||||
|
||||
@@ -35,15 +35,16 @@ impl Handler {
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let arguments = function_arguments(invocation.payload.clone())?;
|
||||
let args: SendMessageArgs = parse_arguments(&arguments)?;
|
||||
handle_message_string_tool(
|
||||
invocation,
|
||||
MessageDeliveryMode::QueueOnly,
|
||||
args.target,
|
||||
args.message,
|
||||
analytics,
|
||||
)
|
||||
.await
|
||||
.map(boxed_tool_output)
|
||||
let mode = if invocation.turn.multi_agent_version
|
||||
== codex_protocol::protocol::MultiAgentVersion::V3
|
||||
{
|
||||
MessageDeliveryMode::WakeWorker
|
||||
} else {
|
||||
MessageDeliveryMode::QueueOnly
|
||||
};
|
||||
handle_message_string_tool(invocation, mode, args.target, args.message, analytics)
|
||||
.await
|
||||
.map(boxed_tool_output)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -764,6 +764,8 @@ fn required_child_management_tool_names(
|
||||
turn_context.config.multi_agent_v2.tool_namespace.as_deref(),
|
||||
if turn_context.config.multi_agent_v2.disable_direct_message {
|
||||
&["interrupt_agent", "list_agents"]
|
||||
} else if turn_context.multi_agent_version == MultiAgentVersion::V3 {
|
||||
&["send_message", "interrupt_agent", "list_agents"]
|
||||
} else {
|
||||
&[
|
||||
"send_message",
|
||||
@@ -1487,26 +1489,36 @@ fn add_collaboration_tools(context: &CoreToolPlanContext<'_>, registry: &mut Too
|
||||
native_review,
|
||||
);
|
||||
if !turn_context.config.multi_agent_v2.disable_direct_message {
|
||||
let v3 = turn_context.multi_agent_version == MultiAgentVersion::V3;
|
||||
let send_message_description = if v3 {
|
||||
Some(
|
||||
"Send a message to an agent. An idle worker starts a new turn in its existing conversation. Messages to /root follow its wake policy.",
|
||||
)
|
||||
} else {
|
||||
model_messages.multi_agent_tool_description_override("send_message")
|
||||
};
|
||||
registry.register_trusted_with_native_review(
|
||||
multi_agent_v2_handler(
|
||||
SendMessageHandlerV2,
|
||||
tool_namespace,
|
||||
model_messages.multi_agent_tool_description_override("send_message"),
|
||||
send_message_description,
|
||||
model_messages.multi_agent_tool_parameters_override("send_message"),
|
||||
),
|
||||
exposure,
|
||||
native_review,
|
||||
);
|
||||
registry.register_trusted_with_native_review(
|
||||
multi_agent_v2_handler(
|
||||
FollowupTaskHandlerV2,
|
||||
tool_namespace,
|
||||
model_messages.multi_agent_tool_description_override("followup_task"),
|
||||
model_messages.multi_agent_tool_parameters_override("followup_task"),
|
||||
),
|
||||
exposure,
|
||||
native_review,
|
||||
);
|
||||
if !v3 {
|
||||
registry.register_trusted_with_native_review(
|
||||
multi_agent_v2_handler(
|
||||
FollowupTaskHandlerV2,
|
||||
tool_namespace,
|
||||
model_messages.multi_agent_tool_description_override("followup_task"),
|
||||
model_messages.multi_agent_tool_parameters_override("followup_task"),
|
||||
),
|
||||
exposure,
|
||||
native_review,
|
||||
);
|
||||
}
|
||||
}
|
||||
if turn_context.config.multi_agent_v2.wait_agent_enabled {
|
||||
registry.register_trusted_with_exposure(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Child history survives interruption and pending mail survives eviction.
|
||||
//! Exercises retained child history and message delivery across interruption and eviction.
|
||||
|
||||
use super::*;
|
||||
use crate::suite::settings_commits::COMMITTED_MODEL;
|
||||
@@ -9,6 +9,7 @@ use codex_extension_api::MessageLifecycleContributor;
|
||||
use codex_extension_api::MessageLifecycleInput;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::protocol::AgentStatus;
|
||||
use codex_protocol::protocol::MultiAgentVersion;
|
||||
use codex_protocol::protocol::Op;
|
||||
use codex_protocol::protocol::TurnAbortReason;
|
||||
use core_test_support::ThreadIdle;
|
||||
@@ -188,6 +189,115 @@ async fn interrupt_retains_one_sampled_item(mut done: serde_json::Value) -> Resu
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn v3_message_wakes_require_a_slot_only_for_idle_workers() -> Result<()> {
|
||||
const BLOCKED: &str = "This attempt should be rejected";
|
||||
const ACTIVE: &str = "Finish the current task";
|
||||
const RETRY: &str = "Continue the original task";
|
||||
skip_if_no_network!(Ok(()));
|
||||
let server = start_mock_server().await;
|
||||
let mut extensions = ExtensionRegistryBuilder::<Config>::new();
|
||||
extensions.thread_lifecycle_contributor(Arc::new(ThreadIdle));
|
||||
let test = test_codex()
|
||||
.with_extensions(Arc::new(extensions.build()))
|
||||
.with_model_info_override("gpt-5.6-sol", |model| {
|
||||
model.multi_agent_version = Some(MultiAgentVersion::V3);
|
||||
model.tool_mode = Some(codex_protocol::openai_models::ToolMode::Direct);
|
||||
})
|
||||
.with_config(|config| {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::MultiAgentV2)
|
||||
.expect("configure agent tools");
|
||||
config
|
||||
.features
|
||||
.disable(Feature::WakeOnAgentMessages)
|
||||
.expect("configure agent tools");
|
||||
config.multi_agent_v2.max_concurrent_threads_per_session = 2;
|
||||
})
|
||||
.build_with_auto_env(&server)
|
||||
.await?;
|
||||
let mut created = test.thread_manager.subscribe_thread_created();
|
||||
let call = async |id, tool, args| {
|
||||
let mock = mount_root_collaboration_call(&server, id, id, tool, args).await;
|
||||
test.submit_turn(id).await?;
|
||||
ThreadIdle::wait(&test.codex).await;
|
||||
mock.function_call_output_text(id)
|
||||
.context("parent tool output")
|
||||
};
|
||||
let spawn = async |id, name: &str, task: &str| {
|
||||
call(
|
||||
id,
|
||||
"spawn_agent",
|
||||
json!({"task_name": name, "message": task, "fork_turns": "none"}),
|
||||
)
|
||||
.await
|
||||
};
|
||||
let send = async |id, target: &str, message: &str| {
|
||||
call(
|
||||
id,
|
||||
"send_message",
|
||||
json!({"target": target, "message": message}),
|
||||
)
|
||||
.await
|
||||
};
|
||||
|
||||
mount_completed_worker(&server, FIRST_TASK, "spawn-first").await;
|
||||
spawn("spawn-first", "first", FIRST_TASK).await?;
|
||||
let first = created.recv().await?;
|
||||
ThreadIdle::wait(test.thread_manager.get_thread(first).await?.as_ref()).await;
|
||||
|
||||
// The second worker owns the only worker slot until a message ends its wait.
|
||||
mount_sse_once_match(
|
||||
&server,
|
||||
|request: &wiremock::Request| {
|
||||
body_contains(request, SECOND_TASK)
|
||||
&& !has_function_call_output(request, "spawn-second")
|
||||
},
|
||||
sse(vec![
|
||||
ev_function_call_with_namespace(
|
||||
"waiting",
|
||||
MULTI_AGENT_V2_NAMESPACE,
|
||||
"wait_agent",
|
||||
"{}",
|
||||
),
|
||||
ev_completed("waiting"),
|
||||
]),
|
||||
)
|
||||
.await;
|
||||
spawn("spawn-second", "second", SECOND_TASK).await?;
|
||||
let second = test
|
||||
.thread_manager
|
||||
.get_thread(created.recv().await?)
|
||||
.await?;
|
||||
wait_for_event(
|
||||
&second,
|
||||
|event| matches!(event, EventMsg::ItemStarted(item) if item.item.id() == "waiting"),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
send("blocked-wake", "first", BLOCKED).await?,
|
||||
"collab tool failed: agent thread limit reached"
|
||||
);
|
||||
let active = mount_completed_worker(&server, ACTIVE, "send-active").await;
|
||||
assert_eq!(send("send-active", "second", ACTIVE).await?, "");
|
||||
ThreadIdle::wait(&second).await;
|
||||
assert!(active.function_call_output_text("waiting").is_some());
|
||||
|
||||
let retry = mount_completed_worker(&server, RETRY, "retry-wake").await;
|
||||
assert_eq!(send("retry-wake", "first", RETRY).await?, "");
|
||||
ThreadIdle::wait(test.thread_manager.get_thread(first).await?.as_ref()).await;
|
||||
let request = retry
|
||||
.requests()
|
||||
.into_iter()
|
||||
.find(|r| r.body_contains_text(RETRY) && !r.has_function_call("retry-wake"))
|
||||
.context("retried worker request")?;
|
||||
assert!(request.body_contains_text(FIRST_TASK));
|
||||
assert!(!request.body_contains_text(BLOCKED));
|
||||
test.codex.shutdown_and_wait().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn idle_mail_survives_eviction_and_preserves_followup_order() -> Result<()> {
|
||||
const MAIL: &str = "Keep this note for later";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Exercises read overlap, ordered identities, and revision-aware history on cold V2 resumes.
|
||||
//! Exercises read overlap, ordered identities, and revision-aware history on cold agent resumes.
|
||||
|
||||
use super::ROLE_MODEL;
|
||||
use super::ROLE_NAME;
|
||||
@@ -15,6 +15,7 @@ use codex_protocol::ThreadId;
|
||||
use codex_protocol::error::CodexErrorDetails;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use codex_protocol::protocol::MultiAgentVersion;
|
||||
use codex_protocol::protocol::ThreadHistoryMode;
|
||||
use codex_thread_store::AppendThreadItemsParams;
|
||||
use codex_thread_store::ArchiveThreadParams;
|
||||
@@ -209,12 +210,19 @@ impl ThreadStore for GatedChildMetadataStore {
|
||||
}
|
||||
}
|
||||
|
||||
#[test_case::test_case(MultiAgentVersion::V2, "followup_task"; "v2")]
|
||||
#[test_case::test_case(MultiAgentVersion::V3, "send_message"; "v3")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn cold_root_resume_overlaps_child_reads_and_applies_identities_in_graph_order() -> Result<()>
|
||||
{
|
||||
async fn cold_root_resume_overlaps_child_reads_and_applies_identities_in_graph_order(
|
||||
version: MultiAgentVersion,
|
||||
followup_tool: &'static str,
|
||||
) -> Result<()> {
|
||||
let server = start_mock_server().await;
|
||||
let initial_url = format!("{}/v1", server.uri());
|
||||
let initial = test_codex()
|
||||
.with_model_info_override("gpt-5.5", move |model| {
|
||||
model.multi_agent_version = Some(version)
|
||||
})
|
||||
.with_config(move |config| {
|
||||
configure_multi_agent_v2_with_role(config, &initial_url);
|
||||
config
|
||||
@@ -334,6 +342,7 @@ async fn cold_root_resume_overlaps_child_reads_and_applies_identities_in_graph_o
|
||||
.context("child metadata reads should overlap")?
|
||||
})?;
|
||||
|
||||
assert_eq!(resumed.codex.multi_agent_version(), Some(version));
|
||||
assert_eq!(resumed.thread_manager.list_thread_ids().await, vec![root]);
|
||||
for child_id in [last, failed] {
|
||||
assert!(matches!(
|
||||
@@ -346,6 +355,7 @@ async fn cold_root_resume_overlaps_child_reads_and_applies_identities_in_graph_o
|
||||
.ensure_multi_agent_v2_child_loaded(first)
|
||||
.await?;
|
||||
let first_child = resumed.thread_manager.get_thread(first).await?;
|
||||
assert_eq!(first_child.multi_agent_version(), Some(version));
|
||||
assert!(resumed.thread_manager.get_thread(last).await.is_err());
|
||||
assert!(resumed.thread_manager.get_thread(failed).await.is_err());
|
||||
|
||||
@@ -353,7 +363,7 @@ async fn cold_root_resume_overlaps_child_reads_and_applies_identities_in_graph_o
|
||||
&server,
|
||||
"continue restored child",
|
||||
"resume-child",
|
||||
"followup_task",
|
||||
followup_tool,
|
||||
&json!({ "target": first.to_string(), "message": "continue after resume" }).to_string(),
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -11,32 +11,47 @@ use core_test_support::responses;
|
||||
use core_test_support::submit_thread_settings;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test_case::test_case(MultiAgentVersion::V2; "v2_followup_task")]
|
||||
#[test_case::test_case(MultiAgentVersion::V3; "v3_encrypted_send_message")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn idle_eviction_preserves_worker_context_for_followup() -> Result<()> {
|
||||
async fn idle_eviction_preserves_worker_context_for_followup(
|
||||
version: MultiAgentVersion,
|
||||
) -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let mut extensions = ExtensionRegistryBuilder::<Config>::new();
|
||||
extensions.thread_lifecycle_contributor(Arc::new(ThreadIdle));
|
||||
let mut test = test_codex()
|
||||
.with_model("gpt-5.6-sol")
|
||||
.with_extensions(Arc::new(extensions.build()))
|
||||
.with_config(|config| {
|
||||
configure_scenario_catalog(config);
|
||||
// This scenario uses client_echo; omit platform-specific shell schemas.
|
||||
config.features.disable(Feature::ShellTool).unwrap();
|
||||
config
|
||||
.features
|
||||
.disable(Feature::ShellTool)
|
||||
.expect("disable shell tools");
|
||||
config
|
||||
.features
|
||||
.enable(Feature::SubagentThreadEnvironments)
|
||||
.expect("enable configured environment inheritance");
|
||||
config.features.enable(Feature::Collab).unwrap();
|
||||
config.features.enable(Feature::MultiAgentV2).unwrap();
|
||||
config
|
||||
.features
|
||||
.enable(Feature::Collab)
|
||||
.expect("enable collaboration");
|
||||
config
|
||||
.features
|
||||
.enable(Feature::MultiAgentV2)
|
||||
.expect("enable the worker runtime");
|
||||
config
|
||||
.features
|
||||
.enable(Feature::MultiAgentV2DynamicTools)
|
||||
.unwrap();
|
||||
.expect("enable worker access to client_echo");
|
||||
config.multi_agent_v2.max_concurrent_threads_per_session = 2;
|
||||
})
|
||||
.with_model_info_override("gpt-5.6-sol", move |model| {
|
||||
model.multi_agent_version = Some(version);
|
||||
})
|
||||
.build_with_auto_env(&server)
|
||||
.await?;
|
||||
// Reuse the client-tool flow to hold each worker result until the parent is idle.
|
||||
@@ -78,6 +93,21 @@ async fn idle_eviction_preserves_worker_context_for_followup() -> Result<()> {
|
||||
let mut created = test.thread_manager.subscribe_thread_created();
|
||||
let mut child_id = None;
|
||||
|
||||
let (idle_tool, idle_arguments, wake_tool, wake_message) = if version == MultiAgentVersion::V3 {
|
||||
(
|
||||
"list_agents",
|
||||
json!({"path_prefix": "/root/worker"}),
|
||||
"send_message",
|
||||
"Continue the migration using the new API.",
|
||||
)
|
||||
} else {
|
||||
(
|
||||
"send_message",
|
||||
json!({"target": "worker", "message": "Use the new API for the migration."}),
|
||||
"followup_task",
|
||||
"Continue the migration with the queued note.",
|
||||
)
|
||||
};
|
||||
for (tool, arguments, answer) in [
|
||||
(
|
||||
"spawn_agent",
|
||||
@@ -87,14 +117,10 @@ async fn idle_eviction_preserves_worker_context_for_followup() -> Result<()> {
|
||||
}),
|
||||
"Mira owns the API migration.",
|
||||
),
|
||||
(idle_tool, idle_arguments, ""),
|
||||
(
|
||||
"send_message",
|
||||
json!({"target": "worker", "message": "Use the new API for the migration."}),
|
||||
"",
|
||||
),
|
||||
(
|
||||
"followup_task",
|
||||
json!({"target": "worker", "message": "Continue the migration with the queued note."}),
|
||||
wake_tool,
|
||||
json!({"target": "worker", "message": wake_message}),
|
||||
"I will continue with Mira using the new API.",
|
||||
),
|
||||
] {
|
||||
@@ -126,7 +152,7 @@ async fn idle_eviction_preserves_worker_context_for_followup() -> Result<()> {
|
||||
sse(vec![ev_completed("parent-done")]),
|
||||
)
|
||||
.await;
|
||||
if tool != "send_message" {
|
||||
if tool != idle_tool {
|
||||
let parent_id = parent_id.clone();
|
||||
responses::mount_sse_once_match(
|
||||
&server,
|
||||
@@ -151,11 +177,11 @@ async fn idle_eviction_preserves_worker_context_for_followup() -> Result<()> {
|
||||
.await?;
|
||||
ThreadIdle::wait(&test.codex).await;
|
||||
|
||||
if tool == "send_message" {
|
||||
if tool == idle_tool {
|
||||
let id = child_id.expect("spawned child");
|
||||
let child = test.thread_manager.get_thread(id).await?;
|
||||
assert_eq!(child.environment_selections().await, configured);
|
||||
// Flush submission dispatch so the note is queued before idle cleanup starts.
|
||||
// Flush submission dispatch before idle cleanup starts.
|
||||
submit_thread_settings(&child, ThreadSettingsOverrides::default()).await?;
|
||||
assert_eq!(
|
||||
test.thread_manager.try_evict_v2_thread(child).await?,
|
||||
@@ -255,8 +281,19 @@ async fn idle_eviction_preserves_worker_context_for_followup() -> Result<()> {
|
||||
false, false, false, false, false, false, false, true, false, true
|
||||
]
|
||||
);
|
||||
let (snapshot, description) = if version == MultiAgentVersion::V3 {
|
||||
(
|
||||
"idle_eviction_v3_send_message",
|
||||
"A V3 parent spawns a worker, checks its status, and sends it an encrypted message after eviction. The same worker resumes with the original assignment and the new message. Complete model streams are grouped as parent, then worker.",
|
||||
)
|
||||
} else {
|
||||
(
|
||||
"idle_eviction_followup",
|
||||
"A parent with no configured environment delegates an API migration, queues a note while the worker is idle, and follows up after idle eviction. The worker temporarily attaches a workspace, then resumes with no environment, its earlier answer, and the unread note. Complete model streams are grouped as parent, then worker.",
|
||||
)
|
||||
};
|
||||
let history = context_snapshot::format_request_history_snapshot(
|
||||
"A parent with no configured environment delegates an API migration, queues a note while the worker is idle, and follows up after idle eviction. The worker temporarily attaches a workspace, then resumes with no environment, its earlier answer, and the unread note. Complete model streams are grouped as parent, then worker.",
|
||||
description,
|
||||
&requests,
|
||||
&ContextSnapshotOptions::default().rewrite_known_segments(),
|
||||
);
|
||||
@@ -273,7 +310,7 @@ async fn idle_eviction_preserves_worker_context_for_followup() -> Result<()> {
|
||||
mailbox.sort_all_objects();
|
||||
let mailbox = serde_json::to_string_pretty(&mailbox)?;
|
||||
insta::assert_snapshot!(
|
||||
"idle_eviction_followup",
|
||||
snapshot,
|
||||
format!("{history}\n\nResumed worker mailbox:\n{mailbox}")
|
||||
);
|
||||
test.thread_manager
|
||||
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
---
|
||||
source: core/tests/suite/scenarios_agent_eviction_tests.rs
|
||||
expression: "format!(\"{history}\\n\\nResumed worker mailbox:\\n{mailbox}\")"
|
||||
---
|
||||
Scenario: A V3 parent spawns a worker, checks its status, and sends it an encrypted message after eviction. The same worker resumes with the original assignment and the new message. Complete model streams are grouped as parent, then worker.
|
||||
|
||||
## Window 1
|
||||
-- request 1 (turn) --
|
||||
00:additional_tools/developer (2; hash=8fbc0ea9adcc0eaf):
|
||||
- namespace/functions; hash=f33f647fee88e25e
|
||||
- custom/exec
|
||||
- function/wait
|
||||
- function/request_user_input
|
||||
- namespace/collaboration: Tools for spawning and managing sub-agents.; hash=e396a572e0f8acf4
|
||||
- function/interrupt_agent
|
||||
- function/list_agents
|
||||
- function/send_message
|
||||
- function/spawn_agent
|
||||
- function/wait_agent
|
||||
01:message/developer:
|
||||
<MODEL_INSTRUCTIONS>
|
||||
02:message/developer:
|
||||
<PERMISSIONS_INSTRUCTIONS>
|
||||
03:message/developer:
|
||||
<MULTI_AGENT_ROLE>
|
||||
04:message/developer:
|
||||
<MULTI_AGENT_MODE>
|
||||
05:message/user:
|
||||
<ENVIRONMENT_CONTEXT>
|
||||
06:message/user:
|
||||
Run spawn_agent for the API migration.
|
||||
-- request 2 (turn) --
|
||||
07:function_call/collaboration.spawn_agent:{"fork_turns":"none","message":"Check who owns the API migration.","task_name":"worker"}
|
||||
08:function_call_output:{"task_name":"/root/worker"}
|
||||
-- request 3 (turn) --
|
||||
09:message/user:
|
||||
Run list_agents for the API migration.
|
||||
-- request 4 (turn) --
|
||||
10:function_call/collaboration.list_agents:{"path_prefix":"/root/worker"}
|
||||
11:function_call_output:{"agents":[{"agent_name":"/root/worker","agent_status":{"completed":"Mira owns the API migration."}}]}
|
||||
12:agent_message
|
||||
-- request 5 (turn) --
|
||||
13:message/user:
|
||||
Run send_message for the API migration.
|
||||
-- request 6 (turn) --
|
||||
14:function_call/collaboration.send_message:{"message":"Continue the migration using the new API.","target":"worker"}
|
||||
15:function_call_output:
|
||||
|
||||
## Window 2 (after request 6: input diverged at item 03)
|
||||
-- request 7 (turn) --
|
||||
00:additional_tools/developer (2; hash=8fbc0ea9adcc0eaf):
|
||||
- namespace/functions; hash=f33f647fee88e25e
|
||||
- custom/exec
|
||||
- function/wait
|
||||
- function/request_user_input
|
||||
- namespace/collaboration: Tools for spawning and managing sub-agents.; hash=e396a572e0f8acf4
|
||||
- function/interrupt_agent
|
||||
- function/list_agents
|
||||
- function/send_message
|
||||
- function/spawn_agent
|
||||
- function/wait_agent
|
||||
01:message/developer:
|
||||
<MODEL_INSTRUCTIONS>
|
||||
02:message/developer:
|
||||
<PERMISSIONS_INSTRUCTIONS>
|
||||
03:message/developer:
|
||||
<MULTI_AGENT_ROLE>
|
||||
04:message/developer:
|
||||
<MULTI_AGENT_MODE>
|
||||
05:message/user:
|
||||
<ENVIRONMENT_CONTEXT>
|
||||
06:agent_message
|
||||
-- request 8 (turn) --
|
||||
07:function_call/client_echo:{"message":"Mira owns the API migration."}
|
||||
08:function_call_output:Mira owns the API migration.
|
||||
09:message/user:
|
||||
<ENVIRONMENT_CONTEXT>
|
||||
-- request 9 (turn) --
|
||||
10:message/assistant:
|
||||
Mira owns the API migration.
|
||||
11:message/user:
|
||||
<ENVIRONMENT_CONTEXT>
|
||||
12:agent_message
|
||||
-- request 10 (turn) --
|
||||
13:function_call/client_echo:{"message":"I will continue with Mira using the new API."}
|
||||
14:function_call_output:I will continue with Mira using the new API.
|
||||
15:message/user:
|
||||
<ENVIRONMENT_CONTEXT>
|
||||
|
||||
Resumed worker mailbox:
|
||||
[
|
||||
{
|
||||
"author": "/root",
|
||||
"content": [
|
||||
{
|
||||
"text": "Message Type: NEW_TASK\nTask name: /root/worker\nSender: /root\nPayload:\n",
|
||||
"type": "input_text"
|
||||
},
|
||||
{
|
||||
"encrypted_content": "Check who owns the API migration.",
|
||||
"type": "encrypted_content"
|
||||
}
|
||||
],
|
||||
"recipient": "/root/worker",
|
||||
"type": "agent_message"
|
||||
},
|
||||
{
|
||||
"author": "/root",
|
||||
"content": [
|
||||
{
|
||||
"text": "Message Type: MESSAGE\nTask name: /root/worker\nSender: /root\nPayload:\n",
|
||||
"type": "input_text"
|
||||
},
|
||||
{
|
||||
"encrypted_content": "Continue the migration using the new API.",
|
||||
"type": "encrypted_content"
|
||||
}
|
||||
],
|
||||
"recipient": "/root/worker",
|
||||
"type": "agent_message"
|
||||
}
|
||||
]
|
||||
@@ -136,6 +136,7 @@ impl<'a> ResolvedModelMessages<'a> {
|
||||
ResolvedMultiAgentMessages::new(
|
||||
self.catalog_messages
|
||||
.and_then(|messages| messages.multi_agent.as_ref()),
|
||||
codex_protocol::protocol::MultiAgentVersion::V2,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
//! Consumers own role assembly, suppression, and effort-dependent mode selection.
|
||||
|
||||
use super::ResolvedMessage;
|
||||
use codex_protocol::openai_models::ModelInfo;
|
||||
use codex_protocol::openai_models::MultiAgentMessages;
|
||||
use codex_protocol::protocol::MultiAgentVersion;
|
||||
|
||||
const DEFAULT_MULTI_AGENT_V2_ROOT_AGENT_USAGE_HINT_TEXT: &str = r#"You are `/root`, the primary agent in a team of agents collaborating to fulfill the user's goals.
|
||||
|
||||
@@ -49,6 +51,7 @@ const PROACTIVE_MULTI_AGENT_MODE_TEXT: &str = "Proactive multi-agent delegation
|
||||
/// Model-only role bases and mode alternatives for runtime selection.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct ResolvedMultiAgentMessages<'a> {
|
||||
pub role_version: MultiAgentVersion,
|
||||
pub root: ResolvedMessage<'a>,
|
||||
pub subagent: ResolvedMessage<'a>,
|
||||
pub explicit: ResolvedMessage<'a>,
|
||||
@@ -58,17 +61,40 @@ pub struct ResolvedMultiAgentMessages<'a> {
|
||||
}
|
||||
|
||||
impl<'a> ResolvedMultiAgentMessages<'a> {
|
||||
pub(crate) fn new(messages: Option<&'a MultiAgentMessages>) -> Self {
|
||||
/// A model inheriting V3 needs roles that describe the tree's tools.
|
||||
pub fn for_roles(version: MultiAgentVersion, model: Option<&'a ModelInfo>) -> Self {
|
||||
let messages = model
|
||||
.filter(|model| {
|
||||
version != MultiAgentVersion::V3 || model.multi_agent_version == Some(version)
|
||||
})
|
||||
.and_then(|model| model.model_messages.as_ref())
|
||||
.and_then(|messages| messages.multi_agent.as_ref());
|
||||
Self::new(messages, version)
|
||||
}
|
||||
|
||||
pub(crate) fn new(
|
||||
messages: Option<&'a MultiAgentMessages>,
|
||||
role_version: MultiAgentVersion,
|
||||
) -> Self {
|
||||
let role = messages.and_then(|messages| messages.role.as_ref());
|
||||
let mode = messages.and_then(|messages| messages.mode.as_ref());
|
||||
Self {
|
||||
root: ResolvedMessage::new(
|
||||
role.and_then(|role| role.root.as_deref()),
|
||||
let (root, subagent) = if role_version == MultiAgentVersion::V3 {
|
||||
(
|
||||
"You are `/root`. Use `spawn_agent` to delegate work. Use `send_message` to give a worker more input, including after it stops.",
|
||||
"You are a worker. Use `send_message` to communicate with your parent or other workers. A message to an idle worker resumes its conversation.",
|
||||
)
|
||||
} else {
|
||||
(
|
||||
DEFAULT_MULTI_AGENT_V2_ROOT_AGENT_USAGE_HINT_TEXT,
|
||||
),
|
||||
DEFAULT_MULTI_AGENT_V2_SUBAGENT_USAGE_HINT_TEXT,
|
||||
)
|
||||
};
|
||||
Self {
|
||||
role_version,
|
||||
root: ResolvedMessage::new(role.and_then(|role| role.root.as_deref()), root),
|
||||
subagent: ResolvedMessage::new(
|
||||
role.and_then(|role| role.subagent.as_deref()),
|
||||
DEFAULT_MULTI_AGENT_V2_SUBAGENT_USAGE_HINT_TEXT,
|
||||
subagent,
|
||||
),
|
||||
explicit: ResolvedMessage::new(
|
||||
mode.and_then(|mode| mode.explicit.as_deref()),
|
||||
|
||||
@@ -25,6 +25,7 @@ pub enum MultiAgentRoleInstructions {
|
||||
Configured(String),
|
||||
/// Selected catalog or bundled text, composed with captured runtime guidance.
|
||||
Composed {
|
||||
version: codex_protocol::protocol::MultiAgentVersion,
|
||||
base: String,
|
||||
omit_update_plan_instructions: bool,
|
||||
max_concurrency: usize,
|
||||
@@ -66,6 +67,7 @@ impl ContextualUserFragment for MultiAgentRoleInstructions {
|
||||
input_text(match self {
|
||||
Self::Configured(text) => text.clone(),
|
||||
Self::Composed {
|
||||
version,
|
||||
base,
|
||||
omit_update_plan_instructions,
|
||||
max_concurrency,
|
||||
@@ -82,7 +84,11 @@ impl ContextualUserFragment for MultiAgentRoleInstructions {
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
let shared = DEFAULT_MULTI_AGENT_V2_SHARED_USAGE_HINT_TEXT;
|
||||
let shared = if *version == codex_protocol::protocol::MultiAgentVersion::V3 {
|
||||
"Agents share the working directory and can see each other's edits.\n"
|
||||
} else {
|
||||
DEFAULT_MULTI_AGENT_V2_SHARED_USAGE_HINT_TEXT
|
||||
};
|
||||
let concurrency = concurrency_guidance(*max_concurrency);
|
||||
let mut text = format!("{base}\n{shared}\n{wait_agent_guidance}{concurrency}");
|
||||
if *expose_model_overrides {
|
||||
|
||||
@@ -15,6 +15,7 @@ fn role_segment_filters_base_and_appends_bundled_guidance() {
|
||||
"Role.\n## Work\nContinue.\n{shared}\n{wait}\n\nThere are 2 available concurrency slots, meaning that up to 2 agents can be active at once, including you.\n\n{model_override}"
|
||||
);
|
||||
let instructions = MultiAgentRoleInstructions::Composed {
|
||||
version: codex_protocol::protocol::MultiAgentVersion::V2,
|
||||
base: "Role.\n## Plan tool\nOmit role checklist guidance.\n## Work\nContinue.".to_string(),
|
||||
omit_update_plan_instructions: true,
|
||||
max_concurrency: 2,
|
||||
|
||||
@@ -1061,13 +1061,21 @@ impl InterAgentCommunication {
|
||||
}
|
||||
|
||||
pub fn to_model_input_item(&self) -> ResponseItem {
|
||||
if self.trigger_turn {
|
||||
self.render_model_input_item("NEW_TASK")
|
||||
} else {
|
||||
self.to_model_input_item_as_message()
|
||||
}
|
||||
}
|
||||
|
||||
/// Render ordinary mail even when its delivery starts a turn.
|
||||
pub fn to_model_input_item_as_message(&self) -> ResponseItem {
|
||||
self.render_model_input_item("MESSAGE")
|
||||
}
|
||||
|
||||
fn render_model_input_item(&self, message_type: &str) -> ResponseItem {
|
||||
let content = match &self.encrypted_content {
|
||||
Some(encrypted_content) => {
|
||||
let message_type = if self.trigger_turn {
|
||||
"NEW_TASK"
|
||||
} else {
|
||||
"MESSAGE"
|
||||
};
|
||||
vec![
|
||||
AgentMessageInputContent::InputText {
|
||||
text: format!(
|
||||
|
||||
Reference in New Issue
Block a user