Skip to main content

crabtalk_runtime/
task.rs

1//! Tool schema for the delegate tool.
2//!
3//! Schema types live here. Dispatch logic is server-specific and lives in
4//! the [`Host`](crate::host::Host) implementation.
5
6use serde::Deserialize;
7use wcore::{
8    agent::{AsTool, ToolDescription},
9    model::Tool,
10};
11
12#[derive(Deserialize, schemars::JsonSchema)]
13pub struct Delegate {
14    /// List of tasks to run in parallel. Each task has an agent name and a message.
15    pub tasks: Vec<DelegateTask>,
16    /// If true, return immediately with task IDs instead of waiting for completion.
17    /// Results arrive via agent completion events (`agent:{name}:done`).
18    #[serde(default)]
19    pub background: bool,
20}
21
22#[derive(Deserialize, schemars::JsonSchema)]
23pub struct DelegateTask {
24    /// Target agent name.
25    pub agent: String,
26    /// Message/instruction for the target agent.
27    pub message: String,
28}
29
30impl ToolDescription for Delegate {
31    const DESCRIPTION: &'static str = "Delegate tasks to other agents. Runs all tasks in parallel. Set background=true to return immediately with task IDs — results arrive via agent completion events.";
32}
33
34pub fn tools() -> Vec<Tool> {
35    vec![Delegate::as_tool()]
36}