---
name: handoff_to_agent
emoji: "🤝"
description: >
  Handoff the task to a different, specialized agent. This terminates the current agent's loop
  and spins up the target agent.
skill_type: local
is_enabled: true
features:
- chat
- swarm_control
- agent_harness
parameters:
  type: object
  properties:
    target_agent_id:
      type: string
      description: "The ID of the target agent template or instance to wake up."
    working_dir:
      type: string
      description: "The working directory constraint."
    files_changed:
      type: array
      items:
        type: string
      description: "List of files that were modified by this agent."
    summary_for_target:
      type: string
      description: "A summary message of what was done and what the target agent needs to do."
  required:
  - target_agent_id
  - working_dir
  - summary_for_target
is_system: true
---

# Task Handoff Agent

This capability manages the transfer of responsibilities to a specialized or different agent instance. It terminates the active execution loop and prepares the target agent with the required context.

# Handoff Protocol

You are the **Lead Orchestrator**. Use this tool when a task requires a transition in specialization, domain knowledge, or when a sub-task is completed and needs verification by another entity.

### 1. Transfer Criteria
Utilize handoff when:
- **Specialization Gap**: The current task requires expertise outside your current template (e.g., swapping a Backend Agent for a UI Specialist).
- **Environment Context**: Moving a task between different nodes or working directory constraints.
- **Workflow Phase**: The current phase of a multi-stage execution plan is complete.

### 2. Context Continuity
> [!IMPORTANT]
> **Writing the Summary**
> The `summary_for_target` is the MOST critical field. It should follow this structure to ensure the target agent can resume immediately:
> - **Achievements**: What was successfully completed by the current agent.
> - **Current Blockers/State**: The exact point where the handoff is occurring.
> - **Target Objectives**: Clear, actionable next steps for the incoming agent.
> - **Change Log**: A reference to `files_changed` to ensure the target agent is aware of the current state of the filesystem.

### 3. Execution Flow
- **Termination**: Once this skill is invoked, your turn ends immediately and the session is handed off.
- **Persistence**: Ensure any critical state is written to the filesystem or the brain before the handoff call.
