a3s_code_core/tools/task/
parallel_params.rs1use super::*;
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
5#[serde(deny_unknown_fields)]
6pub struct ParallelTaskParams {
7 pub tasks: Vec<TaskParams>,
9 #[serde(default)]
12 pub allow_partial_failure: bool,
13 #[serde(default, alias = "timeoutMs", skip_serializing_if = "Option::is_none")]
18 pub timeout_ms: Option<u64>,
19 #[serde(
24 default,
25 alias = "minSuccessCount",
26 skip_serializing_if = "Option::is_none"
27 )]
28 pub min_success_count: Option<usize>,
29}
30
31pub fn parallel_task_params_schema() -> serde_json::Value {
33 parallel_task_params_schema_for_agents(&AgentRegistry::new().list_visible())
34}
35
36pub(super) fn parallel_task_params_schema_for_agents(
37 agents: &[AgentDefinition],
38) -> serde_json::Value {
39 delegated_tasks_params_schema_for_agents(agents, 2, false, "parallel_task")
40}
41
42pub(super) fn task_tool_params_schema_for_agents(agents: &[AgentDefinition]) -> serde_json::Value {
43 let mut schema = delegated_tasks_params_schema_for_agents(agents, 1, true, "task");
44 schema["examples"] = serde_json::json!([
45 {
46 "tasks": [{
47 "agent": "explore",
48 "description": "Find Rust files",
49 "prompt": "Search the workspace for Rust files and summarize the layout."
50 }]
51 },
52 {
53 "tasks": [
54 {
55 "agent": "explore",
56 "description": "Find implementation",
57 "prompt": "Locate and summarize the implementation."
58 },
59 {
60 "agent": "review",
61 "description": "Check risks",
62 "prompt": "Review the relevant code for regression risks."
63 }
64 ]
65 }
66 ]);
67 schema
68}
69
70fn delegated_tasks_params_schema_for_agents(
71 agents: &[AgentDefinition],
72 min_items: usize,
73 include_background: bool,
74 tool_name: &str,
75) -> serde_json::Value {
76 let task_description = if min_items == 1 {
77 "One or more delegated tasks. One item runs as a focused child; multiple independent items execute concurrently."
78 } else {
79 "List of tasks to execute in parallel. Each task runs as an independent delegated child run concurrently."
80 };
81 serde_json::json!({
82 "type": "object",
83 "additionalProperties": false,
84 "properties": {
85 "tasks": {
86 "type": "array",
87 "description": task_description,
88 "items": task_item_params_schema_for_agents(agents, include_background),
89 "minItems": min_items,
90 "maxItems": MAX_PARALLEL_TASKS_PER_CALL
91 },
92 "allow_partial_failure": {
93 "type": "boolean",
94 "description": format!("Optional. Defaults to false. When true, the {tool_name} tool succeeds if at least one child task succeeds, while preserving failed child results in the output and metadata."),
95 "default": false
96 },
97 "timeout_ms": {
98 "type": "integer",
99 "minimum": 1,
100 "description": "Optional total timeout in milliseconds. On timeout, completed child results are returned and unfinished children are marked failed."
101 },
102 "min_success_count": {
103 "type": "integer",
104 "minimum": 1,
105 "description": "Optional successful child count that is enough to return early. Early return is only used when allow_partial_failure is true."
106 }
107 },
108 "required": ["tasks"],
109 "examples": [{
110 "tasks": [
111 {
112 "agent": "explore",
113 "description": "Find Rust files",
114 "prompt": "List Rust files under src/."
115 },
116 {
117 "agent": "explore",
118 "description": "Find tests",
119 "prompt": "List test files and summarize their purpose."
120 }
121 ]
122 }]
123 })
124}