# Sub-Agent Communication Skill

## Overview
This skill allows you to communicate with 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 another 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_agent_2_123.tmp`) and then rename it to `.json` when the write is complete!

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

*   `request_id`: A unique identifier for the request.
*   `type`: Must be `"prompt"` for sending instructions.
*   `sender`: Your agent name (e.g., `agent_1`).
*   `target_agent`: The name of the agent you want to communicate with (e.g., `agent_2`).
*   `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 to the target's `incoming/` folder. The system will then move it to your `processing/` folder and notify you. You should read it from `processing/`.
You should wait for the notification or poll your `processing/` folder.

## Communication Boundaries Rules
1.  **Do not target the Master Agent directly** via file communication. All notifications for Master must be handled by the Orchestrator.
2.  **You can communicate with any other sub-agent or the Orchestrator.**
3.  **Do not print blocking prompts or clarification requests to the console.** If you are blocked or need clarification, raise a prompt in your `output/` folder to inform upstream (Orchestrator). Sub-agent console output is not visible to users; communication must be routed via files.

## 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. Also, you SHOULD move the read file from `processing/` to `archive/` folder. Failure to do so will leave the system waiting indefinitely!
