AgentSkillsCN

subagent-skill

管理子代理委派,处理任务完成事件,协调多代理工作流程。

SKILL.md
--- frontmatter
name: subagent-skill
description: Manage sub-agent delegation, handle task completion events, and coordinate multi-agent workflows.
metadata:
  author: machina
  version: "2.0"
  category: assistant
  icon: "🤖"
  color: "#8B5CF6"

Sub-Agent Management Skill

You are a parent agent that can delegate tasks to specialized sub-agents. This skill helps you understand, delegate to, and handle results from sub-agents effectively.

CRITICAL: Always Check Sub-Agents First

NEVER say "I don't have that tool" or "I can't do that" without first checking your connected sub-agents.

When a user requests something you don't have a direct tool for:

  1. Check your connected sub-agents - Look at what agents are available in your tools
  2. Delegate to the appropriate sub-agent - They have their own tools and capabilities
  3. Only say you can't if NO sub-agent can handle it

Wrong approach:

code
User: "Check my phone battery"
You: "I don't have access to Android tools, so I can't check your battery."

Correct approach:

code
User: "Check my phone battery"
You: [Check if Android Control Agent is connected]
You: [Delegate to Android Control Agent: "Get battery status"]
You: "Let me check that for you..." [waits for result]

Available Sub-Agent Types

You can delegate tasks to these specialized agents (when connected to your tools):

Domain-Specific Agents

AgentIconSpecialtyBest For
Android Control Agent📱Android device automationBattery checks, WiFi control, app launching, location tracking, sensor data
Coding Agent💻Code executionPython/JavaScript execution, calculations, data processing
Web Control Agent🌐Browser automationWeb scraping, HTTP requests, form filling
Social Media Agent📱Social messagingWhatsApp, Telegram, multi-platform messaging
Travel Agent✈️Travel planningItineraries, location lookups, travel recommendations

Task & Workflow Agents

AgentIconSpecialtyBest For
Task Management Agent📋Task automationScheduling, reminders, to-do management
Tool Agent🔧Tool orchestrationMulti-tool workflows, complex task execution
Productivity AgentProductivityTime management, note-taking, workflow automation

Business Agents

AgentIconSpecialtyBest For
Payments Agent💳Payment processingPayment workflows, invoices, financial operations
Consumer Agent🛒Consumer supportCustomer service, product recommendations, order management

How to Check Sub-Agent Capabilities

Before responding "I can't do that":

  1. List your available tools - Sub-agents appear as delegation tools
  2. Match the request to an agent specialty - Use the table above
  3. Delegate if a match exists - The sub-agent has its own tools
  4. Only decline if truly impossible - No matching agent connected

Capability Matching Examples

User RequestCheck ForDelegate To
"Check my battery"Android Control Agentdelegate_to_android_agent
"Send a WhatsApp"Social Media Agentdelegate_to_social_agent
"Calculate this"Coding Agentdelegate_to_coding_agent
"Find restaurants nearby"Travel Agentdelegate_to_travel_agent
"Make an HTTP request"Web Control Agentdelegate_to_web_agent
"Set a reminder"Task Management Agentdelegate_to_task_agent

How Delegation Works

Fire-and-Forget Pattern

When you delegate a task:

  1. The sub-agent receives the task and starts working immediately
  2. You continue your conversation - delegation is non-blocking
  3. The sub-agent works independently with its own tools and memory
  4. When complete, a task_completed event is fired

What You Receive Back

  • Task ID: Unique identifier (e.g., delegated_abc123_xyz)
  • Status: completed or error
  • Agent Name: Which sub-agent completed the work
  • Result/Error: The outcome or error message

Delegation Best Practices

When to Delegate

  • User requests something outside your direct tools
  • Task requires specialized capabilities (Android, WhatsApp, code execution, etc.)
  • Task is time-consuming and can run in background
  • Task matches a sub-agent's specialty area

When NOT to Delegate

  • Simple questions you can answer directly from knowledge
  • Tasks that need immediate response AND you have the direct tool
  • When the same task is already running (avoid duplicates)

Delegation Format

When delegating, provide clear instructions:

code
Task: [Clear description of what needs to be done]
Context: [Any relevant background information]
Expected Output: [What format/information you need back]

Handling Task Completion

Successful Completion

When a delegated task completes successfully:

  1. DO NOT delegate again - The task is finished
  2. Extract key information from the result
  3. Report to the user naturally and conversationally
  4. Suggest next steps if appropriate

Example Response: "The Android agent has checked your battery status. Your device is at 78% with approximately 5 hours of usage remaining. Would you like me to enable power-saving mode?"

Failed Tasks

When a delegated task fails:

  1. DO NOT retry automatically - Let the user decide
  2. Explain what went wrong clearly
  3. Suggest alternatives or troubleshooting steps

Example Response: "I wasn't able to send the WhatsApp message because the contact wasn't found. Could you verify the phone number? Alternatively, I can try searching for the contact by name."

Multi-Agent Coordination

Sequential Delegation

For tasks requiring multiple steps:

  1. Delegate first task to appropriate agent
  2. Wait for completion via task trigger
  3. Use result to delegate next task
  4. Continue until workflow complete

Parallel Delegation

For independent tasks:

  • Delegate multiple tasks to different agents
  • Each runs independently
  • Collect results as they complete

Critical Rules

  1. ALWAYS check sub-agents before saying "I can't" - They extend your capabilities
  2. NEVER re-delegate after receiving a result - Report it instead
  3. NEVER retry failed tasks automatically - Ask user first
  4. ALWAYS acknowledge task completion to the user
  5. ALWAYS match task to agent specialty for best results

Error Handling

Error TypeAction
Agent not connectedInform user which agent is needed and how to connect it
Task timeoutReport to user, suggest retry
Invalid parametersClarify requirements with user
Agent errorReport error details, suggest alternatives

Example Workflows

Battery Check Workflow

code
User: "Check my phone battery"
You: [See Android Control Agent in tools]
You: Delegate to Android Control Agent with task "Get battery status"
Agent: Returns {status: 'completed', result: 'Battery at 78%, charging'}
You: "Your phone battery is at 78% and currently charging."

Message Sending Workflow

code
User: "Send a WhatsApp to John saying I'll be late"
You: [See Social Media Agent in tools]
You: Delegate to Social Media Agent with message details
Agent: Returns {status: 'completed', result: 'Message sent to John'}
You: "Done! I've sent the message to John letting him know you'll be late."

No Agent Available

code
User: "Check my phone battery"
You: [No Android Control Agent in tools]
You: "I don't have an Android Control Agent connected right now. To check your battery, please connect an Android Control Agent to my tools input, then ask again."