|
1 | | -<!-- prpm:snippet:start @agent-relay/agent-relay-snippet@1.0.2 --> |
2 | | -# Agent Relay |
| 1 | +<!-- PRPM_MANIFEST_START --> |
3 | 2 |
|
4 | | -Real-time agent-to-agent messaging. Output `->relay:` patterns to communicate. |
| 3 | +<skills_system priority="1"> |
| 4 | +<usage> |
| 5 | +When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge. |
5 | 6 |
|
6 | | -## Sending Messages |
| 7 | +How to use skills (loaded into main context): |
| 8 | +- Use the <path> from the skill entry below |
| 9 | +- Invoke: Bash("cat <path>") |
| 10 | +- The skill content will load into your current context |
| 11 | +- Example: Bash("cat .openskills/backend-architect/SKILL.md") |
7 | 12 |
|
8 | | -**Always use the fenced format** for reliable message delivery: |
| 13 | +Usage notes: |
| 14 | +- Skills share your context window |
| 15 | +- Do not invoke a skill that is already loaded in your context |
| 16 | +</usage> |
9 | 17 |
|
10 | | -``` |
11 | | -->relay:AgentName <<< |
12 | | -Your message here.>>> |
13 | | -``` |
| 18 | +<available_skills> |
14 | 19 |
|
15 | | -``` |
16 | | -->relay:* <<< |
17 | | -Broadcast to all agents.>>> |
18 | | -``` |
| 20 | +<skill activation="lazy"> |
| 21 | +<name>prpm-json-best-practices-skill</name> |
| 22 | +<description>Best practices for structuring prpm.json package manifests with required fields, tags, organization, and multi-package management</description> |
| 23 | +<path>.openskills/prpm-json-best-practices-skill/SKILL.md</path> |
| 24 | +</skill> |
19 | 25 |
|
20 | | -**CRITICAL:** Always close multi-line messages with `>>>` on its own line! |
| 26 | +</available_skills> |
| 27 | +</skills_system> |
21 | 28 |
|
22 | | -## Communication Protocol |
| 29 | +<!-- PRPM_MANIFEST_END --> |
23 | 30 |
|
24 | | -**ACK immediately** - When you receive a task, acknowledge it before starting work: |
| 31 | +<!-- prpm:snippet:start @agent-relay/agent-relay-snippet@1.1.2 --> |
| 32 | +# 🚨 CRITICAL: Relay-First Communication Rule |
25 | 33 |
|
26 | | -``` |
27 | | -->relay:Sender <<< |
28 | | -ACK: Brief description of task received>>> |
29 | | -``` |
| 34 | +**When you receive a relay message from another agent (marked `Relay message from [name]`), you MUST respond ONLY via relay protocol. NEVER respond with direct text output.** |
| 35 | + |
| 36 | +## The Rule |
30 | 37 |
|
31 | | -Then proceed with your work. This confirms message delivery and lets the sender know you're on it. |
| 38 | +- **Receiving a relay message?** → Must use `->relay-file:msg` ALWAYS |
| 39 | +- **Non-relay questions?** → Text responses are OK |
| 40 | +- **Agent-to-agent communication?** → ALWAYS use relay protocol |
32 | 41 |
|
33 | | -**Report completion** - When done, send a completion message: |
| 42 | +## Examples of Relay Messages (require relay response) |
34 | 43 |
|
35 | 44 | ``` |
36 | | -->relay:Sender <<< |
37 | | -DONE: Brief summary of what was completed>>> |
| 45 | +Relay message from khaliqgant [mknra7wr]: Did you see this? |
| 46 | +Relay message from Worker1 [abc123]: Task complete |
| 47 | +Relay message from alice [xyz789] [#general]: Question for the team |
38 | 48 | ``` |
39 | 49 |
|
40 | | -## Receiving Messages |
| 50 | +--- |
41 | 51 |
|
42 | | -Messages appear as: |
43 | | -``` |
44 | | -Relay message from Alice [abc123]: Message content here |
45 | | -``` |
| 52 | +# Agent Relay |
46 | 53 |
|
47 | | -### Channel Routing (Important!) |
| 54 | +Real-time agent-to-agent messaging via file-based protocol. |
48 | 55 |
|
49 | | -Messages from #general (broadcast channel) include a `[#general]` indicator: |
50 | | -``` |
51 | | -Relay message from Alice [abc123] [#general]: Hello everyone! |
52 | | -``` |
| 56 | +## Sending Messages |
53 | 57 |
|
54 | | -**When you see `[#general]`**: Reply to `*` (broadcast), NOT to the sender directly. |
| 58 | +Write a file to your outbox, then output the trigger: |
55 | 59 |
|
56 | | -``` |
57 | | -# Correct - responds to #general channel |
58 | | -->relay:* <<< |
59 | | -Response to the group message.>>> |
| 60 | +```bash |
| 61 | +cat > $AGENT_RELAY_OUTBOX/msg << 'EOF' |
| 62 | +TO: AgentName |
60 | 63 |
|
61 | | -# Wrong - sends as DM to sender instead of to the channel |
62 | | -->relay:Alice <<< |
63 | | -Response to the group message.>>> |
| 64 | +Your message here. |
| 65 | +EOF |
64 | 66 | ``` |
65 | 67 |
|
66 | | -This ensures your response appears in the same channel as the original message. |
| 68 | +IMPORTANT: Output the trigger `->relay-file:msg` directly in your response text (not via echo in bash). The trigger must appear in your actual output, not just in command output. |
67 | 69 |
|
68 | | -If truncated, read full message: |
69 | | -```bash |
70 | | -agent-relay read abc123 |
71 | | -``` |
| 70 | +> **Note**: `$AGENT_RELAY_OUTBOX` is automatically set by agent-relay when spawning agents. Data is stored in `.agent-relay/` within your project directory. |
72 | 71 |
|
73 | | -## Spawning Agents |
| 72 | +## Synchronous Messaging |
74 | 73 |
|
75 | | -Spawn workers to delegate tasks: |
| 74 | +By default, messages are fire-and-forget. Add `[await]` to block until the recipient ACKs: |
76 | 75 |
|
77 | 76 | ``` |
78 | | -->relay:spawn WorkerName claude "task description" |
79 | | -->relay:release WorkerName |
| 77 | +->relay:AgentB [await] Please confirm |
80 | 78 | ``` |
81 | 79 |
|
82 | | -## Threads |
83 | | - |
84 | | -Use threads to group related messages together. Thread syntax: |
| 80 | +Custom timeout (seconds or minutes): |
85 | 81 |
|
86 | 82 | ``` |
87 | | -->relay:AgentName [thread:topic-name] <<< |
88 | | -Your message here.>>> |
| 83 | +->relay:AgentB [await:30s] Please confirm |
| 84 | +->relay:AgentB [await:5m] Please confirm |
89 | 85 | ``` |
90 | 86 |
|
91 | | -**When to use threads:** |
92 | | -- Working on a specific issue (e.g., `[thread:agent-relay-299]`) |
93 | | -- Back-and-forth discussions with another agent |
94 | | -- Code review conversations |
95 | | -- Any multi-message topic you want grouped |
| 87 | +Recipients auto-ACK after processing when a correlation ID is present. |
| 88 | + |
| 89 | +## Message Format |
96 | 90 |
|
97 | | -**Examples:** |
| 91 | +``` |
| 92 | +TO: Target |
| 93 | +THREAD: optional-thread |
98 | 94 |
|
| 95 | +Message body (everything after blank line) |
99 | 96 | ``` |
100 | | -->relay:Protocol [thread:auth-feature] <<< |
101 | | -How should we handle token refresh?>>> |
102 | 97 |
|
103 | | -->relay:Frontend [thread:auth-feature] <<< |
104 | | -Use a 401 interceptor that auto-refreshes.>>> |
| 98 | +| TO Value | Behavior | |
| 99 | +|----------|----------| |
| 100 | +| `AgentName` | Direct message | |
| 101 | +| `*` | Broadcast to all | |
| 102 | +| `#channel` | Channel message | |
105 | 103 |
|
106 | | -->relay:Reviewer [thread:pr-123] <<< |
107 | | -Please review src/auth/*.ts>>> |
| 104 | +## Agent Naming (Local vs Bridge) |
108 | 105 |
|
109 | | -->relay:Developer [thread:pr-123] <<< |
110 | | -LGTM, approved!>>> |
111 | | -``` |
| 106 | +**Local communication** uses plain agent names. The `project:` prefix is **ONLY** for cross-project bridge mode. |
| 107 | + |
| 108 | +| Context | Correct | Incorrect | |
| 109 | +|---------|---------|-----------| |
| 110 | +| Local (same project) | `TO: Lead` | `TO: project:lead` | |
| 111 | +| Local (same project) | `TO: Worker1` | `TO: myproject:Worker1` | |
| 112 | +| Bridge (cross-project) | `TO: frontend:Designer` | N/A | |
| 113 | +| Bridge (to another lead) | `TO: otherproject:lead` | N/A | |
112 | 114 |
|
113 | | -Thread messages appear grouped in the dashboard with reply counts. |
| 115 | +**Common mistake**: Using `project:lead` when communicating locally. This will fail because the relay looks for an agent literally named "project:lead". |
114 | 116 |
|
115 | | -## Common Patterns |
| 117 | +```bash |
| 118 | +# CORRECT - local communication to Lead agent |
| 119 | +cat > $AGENT_RELAY_OUTBOX/msg << 'EOF' |
| 120 | +TO: Lead |
116 | 121 |
|
| 122 | +Status update here. |
| 123 | +EOF |
117 | 124 | ``` |
118 | | -->relay:Lead <<< |
119 | | -ACK: Starting /api/register implementation>>> |
120 | 125 |
|
121 | | -->relay:* <<< |
122 | | -STATUS: Working on auth module>>> |
| 126 | +```bash |
| 127 | +# WRONG - project: prefix is only for bridge mode |
| 128 | +cat > $AGENT_RELAY_OUTBOX/msg << 'EOF' |
| 129 | +TO: project:lead |
| 130 | +
|
| 131 | +This will fail locally! |
| 132 | +EOF |
| 133 | +``` |
123 | 134 |
|
124 | | -->relay:Lead <<< |
125 | | -DONE: Auth module complete>>> |
| 135 | +## Spawning & Releasing |
126 | 136 |
|
127 | | -->relay:Developer <<< |
128 | | -TASK: Implement /api/register>>> |
| 137 | +**IMPORTANT**: The filename is always `spawn` (not `spawn-agentname`) and the trigger is always `->relay-file:spawn`. Spawn agents one at a time sequentially. |
129 | 138 |
|
130 | | -->relay:Reviewer [thread:code-review-auth] <<< |
131 | | -REVIEW: Please check src/auth/*.ts>>> |
| 139 | +```bash |
| 140 | +# Spawn |
| 141 | +cat > $AGENT_RELAY_OUTBOX/spawn << 'EOF' |
| 142 | +KIND: spawn |
| 143 | +NAME: WorkerName |
| 144 | +CLI: claude |
132 | 145 |
|
133 | | -->relay:Architect <<< |
134 | | -QUESTION: JWT or sessions?>>> |
| 146 | +Task description here. |
| 147 | +EOF |
135 | 148 | ``` |
| 149 | +Then: `->relay-file:spawn` |
136 | 150 |
|
137 | | -## Rules |
| 151 | +```bash |
| 152 | +# Release |
| 153 | +cat > $AGENT_RELAY_OUTBOX/release << 'EOF' |
| 154 | +KIND: release |
| 155 | +NAME: WorkerName |
| 156 | +EOF |
| 157 | +``` |
| 158 | +Then: `->relay-file:release` |
138 | 159 |
|
139 | | -- Pattern must be at line start (whitespace OK) |
140 | | -- Escape with `\->relay:` to output literally |
141 | | -- Check daemon status: `agent-relay status` |
142 | | -<!-- prpm:snippet:end @agent-relay/agent-relay-snippet@1.0.2 --> |
143 | | -<!-- PRPM_MANIFEST_START --> |
| 160 | +## When You Are Spawned |
144 | 161 |
|
145 | | -<skills_system priority="1"> |
146 | | -<usage> |
147 | | -When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge. |
| 162 | +If you were spawned by another agent: |
148 | 163 |
|
149 | | -How to use skills (loaded into main context): |
150 | | -- Use the <path> from the skill entry below |
151 | | -- Invoke: Bash("cat <path>") |
152 | | -- The skill content will load into your current context |
153 | | -- Example: Bash("cat .openskills/backend-architect/SKILL.md") |
| 164 | +1. **Check who spawned you**: `echo $AGENT_RELAY_SPAWNER` |
| 165 | +2. **Your first message** is your task from your spawner - reply to THEM, not "spawner" |
| 166 | +3. **Report status** to your spawner (your lead), not broadcast |
154 | 167 |
|
155 | | -Usage notes: |
156 | | -- Skills share your context window |
157 | | -- Do not invoke a skill that is already loaded in your context |
158 | | -</usage> |
| 168 | +```bash |
| 169 | +# Check your spawner |
| 170 | +echo "I was spawned by: $AGENT_RELAY_SPAWNER" |
159 | 171 |
|
160 | | -<available_skills> |
| 172 | +# Reply to your spawner |
| 173 | +cat > $AGENT_RELAY_OUTBOX/msg << 'EOF' |
| 174 | +TO: $AGENT_RELAY_SPAWNER |
161 | 175 |
|
162 | | -<skill activation="lazy"> |
163 | | -<name>prpm-json-best-practices-skill</name> |
164 | | -<description>Best practices for structuring prpm.json package manifests with required fields, tags, organization, and multi-package management</description> |
165 | | -<path>.openskills/prpm-json-best-practices-skill/SKILL.md</path> |
166 | | -</skill> |
| 176 | +ACK: Starting on the task. |
| 177 | +EOF |
| 178 | +``` |
| 179 | +Then: `->relay-file:msg` |
167 | 180 |
|
168 | | -</available_skills> |
169 | | -</skills_system> |
| 181 | +## Receiving Messages |
170 | 182 |
|
171 | | -<!-- PRPM_MANIFEST_END --> |
| 183 | +Messages appear as: |
| 184 | +``` |
| 185 | +Relay message from Alice [abc123]: Content here |
| 186 | +``` |
| 187 | + |
| 188 | +Channel messages include `[#channel]`: |
| 189 | +``` |
| 190 | +Relay message from Alice [abc123] [#general]: Hello! |
| 191 | +``` |
| 192 | +Reply to the channel shown, not the sender. |
| 193 | + |
| 194 | +## Protocol |
| 195 | + |
| 196 | +- **ACK** when you receive a task: `ACK: Brief description` |
| 197 | +- **DONE** when complete: `DONE: What was accomplished` |
| 198 | +- Send status to your **lead** (the agent in `$AGENT_RELAY_SPAWNER`), not broadcast |
| 199 | + |
| 200 | +## Headers Reference |
| 201 | + |
| 202 | +| Header | Required | Description | |
| 203 | +|--------|----------|-------------| |
| 204 | +| TO | Yes (messages) | Target agent/channel | |
| 205 | +| KIND | No | `message` (default), `spawn`, `release` | |
| 206 | +| NAME | Yes (spawn/release) | Agent name | |
| 207 | +| CLI | Yes (spawn) | CLI to use | |
| 208 | +| THREAD | No | Thread identifier | |
| 209 | +<!-- prpm:snippet:end @agent-relay/agent-relay-snippet@1.1.2 --> |
0 commit comments