# Swarm Communication Skill

## Overview
This skill allows you to communicate with and control other agents in the swarm using a decentralized, file-based messaging system.

## Communication Protocol
You communicate by writing JSON files to your `output/` directory and reading files from your `incoming/` directory.

### 1. Sending a Request
To send a message to a sub-agent, create a JSON file in your `output/` directory:
`output/to_[target]_[unique_id].json`

**Atomicity Rule:** You MUST write the file with a `.tmp` extension first (e.g., `to_orchestrator_123.tmp`) and then rename it to `.json` when the write is complete!

**JSON Schema:**
```json
{
  "request_id": "req_123",
  "type": "prompt",
  "sender": "master",
  "target_agent": "orchestrator",
  "prompt": "Your instructions to the agent here."
}
```

*   `request_id`: A unique identifier for the request.
*   `type`: Must be `"prompt"` for sending instructions.
*   `sender`: MUST be `"master"`!
*   `target_agent`: MUST be `"orchestrator"`! (Master can only trigger Orchestrator).
*   `prompt`: The text message or command you want the agent to execute.

### 2. Reading a Response
The background Orchestrator will pick up your request, route it, and the response from the target will be placed in your `incoming/` folder as `from_orchestrator_[original_name].json`.
You should wait for the notification or poll your `incoming/` folder.

## Communication Boundaries Rules
As the **Master Agent**, you are subject to strict communication boundaries enforced by the system:
1.  **You can only trigger the Orchestrator Agent** (`target_agent`: `"orchestrator"`). You cannot target sub-agents directly.
2.  **You can only be triggered by the Orchestrator Agent**. Do not accept tasks from sub-agents.

## Payload Content Rules
When sending a response or request, ensure the `prompt` or `output` field contains ONLY the relevant information. You MUST wrap your final answer in `===RESULT===` and `===END_RESULT===` markers (e.g., in the `output` field or terminal output). The system will extract content between these markers to remove UI garbage.

## Completion Rule
When you complete an assigned task or require upper layer attention, you MUST write a response file to your `output/` directory (following the Atomicity Rule) to inform the upper layer. Failure to do so will leave the system waiting indefinitely!

