Remove queue message tool

This commit is contained in:
Eric Traut
2026-04-10 00:19:23 -07:00
parent 1460cc5ff5
commit b60311ab2a
9 changed files with 5 additions and 167 deletions

View File

@@ -12,7 +12,6 @@ use super::INITIAL_SUBMIT_ID;
use super::Session;
use crate::messages::MessageInvocationContext;
use crate::messages::MessagePayload;
use crate::messages::ThreadMessage;
use crate::messages::db_message_to_thread_message;
use crate::messages::injected_message_event;
use crate::messages::message_prompt_input_item;
@@ -185,46 +184,6 @@ impl Session {
Ok(true)
}
pub(crate) async fn queue_message_to_thread(
self: &Arc<Self>,
thread_id: String,
payload: MessagePayload,
delivery: TimerDelivery,
) -> Result<ThreadMessage, String> {
validate_meta(&payload.meta)?;
let state_db = self.timer_state_db().await?;
self.start_timer_db_sync_task(state_db.clone());
let MessagePayload {
content,
instructions,
meta,
} = payload;
let params = codex_state::ThreadMessageCreateParams::new(
thread_id,
format!("thread {}", self.thread_id_string()),
content,
instructions,
serde_json::to_string(&meta)
.map_err(|err| format!("failed to serialize message metadata: {err}"))?,
delivery.as_str().to_string(),
Utc::now().timestamp(),
);
state_db
.create_thread_message(&params)
.await
.map_err(|err| format!("failed to queue message in sqlite: {err}"))?;
Ok(ThreadMessage {
id: params.id,
thread_id: params.thread_id,
source: params.source,
content: params.content,
instructions: params.instructions,
meta,
delivery,
queued_at: params.queued_at,
})
}
pub(crate) async fn maybe_start_pending_timer(self: &Arc<Self>) {
if !self.try_start_pending_timer().await {
self.maybe_start_pending_message().await;

View File

@@ -51,7 +51,6 @@ pub use test_sync::TestSyncHandler;
pub use timers::CreateTimerHandler;
pub use timers::DeleteTimerHandler;
pub use timers::ListTimersHandler;
pub use timers::QueueMessageHandler;
pub use tool_search::ToolSearchHandler;
pub use tool_suggest::ToolSuggestHandler;
pub use unified_exec::UnifiedExecHandler;

View File

@@ -1,7 +1,7 @@
//! Built-in tool handlers for thread-local persistent timer management.
//!
//! These handlers bridge timer and queued-message tool calls onto the current
//! thread session's timer registry.
//! These handlers bridge timer tool calls onto the current thread session's
//! timer registry.
use serde::Deserialize;
use std::collections::BTreeMap;
@@ -33,21 +33,6 @@ struct DeleteTimerArgs {
id: String,
}
#[derive(Deserialize)]
struct QueueMessageArgs {
thread_id: String,
content: String,
instructions: Option<String>,
#[serde(default)]
meta: BTreeMap<String, String>,
#[serde(default = "default_delivery")]
delivery: TimerDelivery,
}
fn default_delivery() -> TimerDelivery {
TimerDelivery::AfterTurn
}
pub struct CreateTimerHandler;
impl ToolHandler for CreateTimerHandler {
@@ -87,42 +72,6 @@ impl ToolHandler for CreateTimerHandler {
}
}
pub struct QueueMessageHandler;
impl ToolHandler for QueueMessageHandler {
type Output = FunctionToolOutput;
fn kind(&self) -> ToolKind {
ToolKind::Function
}
async fn handle(&self, invocation: ToolInvocation) -> Result<Self::Output, FunctionCallError> {
let ToolPayload::Function { arguments } = invocation.payload else {
return Err(FunctionCallError::RespondToModel(
"queue_message received unsupported payload".to_string(),
));
};
let args: QueueMessageArgs = parse_arguments(&arguments)?;
let message = invocation
.session
.queue_message_to_thread(
args.thread_id,
MessagePayload {
content: args.content,
instructions: args.instructions,
meta: args.meta,
},
args.delivery,
)
.await
.map_err(FunctionCallError::RespondToModel)?;
let content = serde_json::to_string(&message).map_err(|err| {
FunctionCallError::Fatal(format!("failed to serialize queue_message response: {err}"))
})?;
Ok(FunctionToolOutput::from_text(content, Some(true)))
}
}
pub struct DeleteTimerHandler;
impl ToolHandler for DeleteTimerHandler {

View File

@@ -3,7 +3,6 @@ use crate::shell::ShellType;
use crate::tools::handlers::CreateTimerHandler;
use crate::tools::handlers::DeleteTimerHandler;
use crate::tools::handlers::ListTimersHandler;
use crate::tools::handlers::QueueMessageHandler;
use crate::tools::handlers::agent_jobs::BatchJobHandler;
use crate::tools::handlers::multi_agents_common::DEFAULT_WAIT_TIMEOUT_MS;
use crate::tools::handlers::multi_agents_common::MAX_WAIT_TIMEOUT_MS;
@@ -174,9 +173,6 @@ pub(crate) fn build_specs_with_discoverable_tools(
ToolHandlerKind::ListTimers => {
builder.register_handler(handler.name, Arc::new(ListTimersHandler));
}
ToolHandlerKind::QueueMessage => {
builder.register_handler(handler.name, Arc::new(QueueMessageHandler));
}
ToolHandlerKind::AgentJobs => {
builder.register_handler(handler.name, Arc::new(BatchJobHandler));
}

View File

@@ -92,7 +92,6 @@ pub use responses_api::mcp_tool_to_responses_api_tool;
pub use responses_api::tool_definition_to_responses_api_tool;
pub use timer_tool::create_delete_timer_tool;
pub use timer_tool::create_list_timers_tool;
pub use timer_tool::create_queue_message_tool;
pub use timer_tool::create_timer_tool;
pub use tool_config::ShellCommandBackendConfig;
pub use tool_config::ToolUserShellType;

View File

@@ -1,7 +1,7 @@
//! Responses API tool specs for thread-local persistent timer and message management.
//! Responses API tool specs for thread-local persistent timer management.
//!
//! These specs expose the `create_timer`, `delete_timer`, `list_timers`, and
//! `queue_message` built-in tools.
//! These specs expose the `create_timer`, `delete_timer`, and `list_timers`
//! built-in tools.
use crate::JsonSchema;
use crate::ResponsesApiTool;
@@ -95,53 +95,6 @@ pub fn create_timer_tool() -> ToolSpec {
})
}
pub fn create_queue_message_tool() -> ToolSpec {
let properties = BTreeMap::from([
(
"thread_id".to_string(),
JsonSchema::string(Some(
"Target thread id that should receive the queued message.".to_string(),
)),
),
(
"content".to_string(),
JsonSchema::string(Some(
"Message content visible in the target thread transcript.".to_string(),
)),
),
(
"instructions".to_string(),
JsonSchema::string(Some(
"Optional model-visible instructions hidden from transcript display.".to_string(),
)),
),
(
"meta".to_string(),
JsonSchema::object(BTreeMap::new(), None, Some(true.into())),
),
(
"delivery".to_string(),
JsonSchema::string(Some(
"Delivery mode for the message. Use `after-turn` or `steer-current-turn`."
.to_string(),
)),
),
]);
ToolSpec::Function(ResponsesApiTool {
name: "queue_message".to_string(),
description: "Queue a message for delivery to a target thread.".to_string(),
strict: false,
defer_loading: None,
parameters: JsonSchema::object(
properties,
Some(vec!["thread_id".to_string(), "content".to_string()]),
Some(false.into()),
),
output_schema: None,
})
}
pub fn create_delete_timer_tool() -> ToolSpec {
let properties = BTreeMap::from([(
"id".to_string(),

View File

@@ -4,7 +4,6 @@ use pretty_assertions::assert_eq;
use super::create_delete_timer_tool;
use super::create_list_timers_tool;
use super::create_queue_message_tool;
use super::create_timer_tool;
#[test]
@@ -30,11 +29,3 @@ fn timer_list_tool_uses_expected_name() {
};
assert_eq!(name, "list_timers");
}
#[test]
fn message_queue_tool_uses_expected_name() {
let ToolSpec::Function(ResponsesApiTool { name, .. }) = create_queue_message_tool() else {
panic!("expected function tool");
};
assert_eq!(name, "queue_message");
}

View File

@@ -34,7 +34,6 @@ use crate::create_list_mcp_resource_templates_tool;
use crate::create_list_mcp_resources_tool;
use crate::create_list_timers_tool;
use crate::create_local_shell_tool;
use crate::create_queue_message_tool;
use crate::create_read_mcp_resource_tool;
use crate::create_report_agent_job_result_tool;
use crate::create_request_permissions_tool;
@@ -252,11 +251,6 @@ pub fn build_tool_registry_plan(
}
if config.timer_scheduler {
plan.push_spec(
create_queue_message_tool(),
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
plan.push_spec(
create_timer_tool(),
/*supports_parallel_tool_calls*/ false,
@@ -272,7 +266,6 @@ pub fn build_tool_registry_plan(
/*supports_parallel_tool_calls*/ false,
config.code_mode_enabled,
);
plan.register_handler("queue_message", ToolHandlerKind::QueueMessage);
plan.register_handler("create_timer", ToolHandlerKind::CreateTimer);
plan.register_handler("delete_timer", ToolHandlerKind::DeleteTimer);
plan.register_handler("list_timers", ToolHandlerKind::ListTimers);

View File

@@ -14,7 +14,6 @@ pub enum ToolHandlerKind {
CreateTimer,
DeleteTimer,
ListTimers,
QueueMessage,
AgentJobs,
ApplyPatch,
CloseAgentV1,