Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src-tauri/src/acp/delegation/companion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,25 @@ mod tests {
assert!(status["inputSchema"]["properties"]["wait_ms"].is_object());
let required = status["inputSchema"]["required"].as_array().unwrap();
assert!(required.iter().any(|v| v == "task_ids"));
// Self-initiate is allowed: a mention is sufficient, not required.
// The old copy said a mention IS the trigger, so agents waited for `@`.
let desc = delegate["description"].as_str().unwrap();
assert!(
desc.contains("YOU MAY CALL THIS TOOL WITHOUT A USER @ MENTION"),
"delegate_to_agent must invite self-initiated spawn"
);
assert!(
desc.contains("Such a mention MUST be honored"),
"an @ mention must still force a delegation"
);
assert!(
!desc.contains("Such a mention IS an explicit instruction"),
"do not tell the model that only a mention starts a sub-agent"
);
let agent_desc = delegate["inputSchema"]["properties"]["agent_type"]["description"]
.as_str()
.unwrap();
assert!(agent_desc.contains("even when the user did not @-mention"));
}

#[tokio::test]
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/acp/delegation/tool_schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"name": "delegate_to_agent",
"description": "Hand off a self-contained sub-task to a separate local AI agent that runs in its own session. ASYNCHRONOUS: returns a task_id right away and the sub-agent keeps working in the background — this call never blocks. So you can fan out several delegations at once and keep working, then collect the results with get_delegation_status by passing the task_ids array (one id to poll a single task, or many at once to poll the whole fan-out in one call) — or stop one early with cancel_delegation(task_id). The sub-agent CANNOT see this conversation, your open files, or earlier turns — it starts cold, so `task` must carry everything it needs. Best for independent, parallelizable work you can describe up front; not for steps that need your ongoing back-and-forth. RECOGNIZING AN EXPLICIT DELEGATION REQUEST: the user can name a sub-agent directly in their message — it appears as `@AgentName` or as a Markdown link `[@AgentName](codeg://agent/<agent_type>)`. Such a mention IS an explicit instruction to delegate the associated work to that agent, even when the user never names this tool. If the message names several agents, make one call per agent, each carrying that agent's slice of the work.",
"description": "Hand off a self-contained sub-task to a separate local AI agent that runs in its own session. ASYNCHRONOUS: returns a task_id right away and the sub-agent keeps working in the background — this call never blocks. So you can fan out several delegations at once and keep working, then collect the results with get_delegation_status by passing the task_ids array (one id to poll a single task, or many at once to poll the whole fan-out in one call) — or stop one early with cancel_delegation(task_id). The sub-agent CANNOT see this conversation, your open files, or earlier turns — it starts cold, so `task` must carry everything it needs. Best for independent, parallelizable work you can describe up front; not for steps that need your ongoing back-and-forth. YOU MAY CALL THIS TOOL WITHOUT A USER @ MENTION. When the request has a self-contained sub-task that another listed agent is better suited for, or that can run in parallel, spawn it yourself. Pick agent_type only from this tool's enum (the built-ins listed here plus any custom:<id> slugs shown). Do not invent slugs. Do not copy the whole conversation into the child — only a self-contained slice. Then keep working, or collect results with get_delegation_status. RECOGNIZING AN EXPLICIT DELEGATION REQUEST: the user can name a sub-agent directly in their message — it appears as `@AgentName` or as a Markdown link `[@AgentName](codeg://agent/<agent_type>)`. Such a mention MUST be honored: delegate the associated work to that agent even when the user never names this tool. If the message names several agents, make one call per agent, each carrying that agent's slice of the work.",
"inputSchema": {
"type": "object",
"required": ["agent_type", "task"],
Expand All @@ -22,7 +22,7 @@
"grok",
"cursor"
],
"description": "Which local agent runs the sub-task. Pick the one best suited to the work — or, when the user's message names an agent via `@AgentName` / `codeg://agent/<agent_type>`, use that exact `<agent_type>` slug (e.g. `codeg://agent/claude_code` means `claude_code`)."
"description": "Which local agent runs the sub-task. You may pick the one best suited to the work even when the user did not @-mention anyone. When the user's message names an agent via `@AgentName` / `codeg://agent/<agent_type>`, use that exact `<agent_type>` slug (e.g. `codeg://agent/claude_code` means `claude_code`)."
},
"task": {
"type": "string",
Expand Down
Loading