@@ -11,42 +11,100 @@ Enable turn-based agent collaboration, clean phase transitions, manual compressi
1111
1212## The Four Pillars
1313
14+ ### 🔀 ** PARALLELIZE** — Explore Multiple Approaches
15+
16+ Branch into independent sessions to try different solutions. Full primary agent capabilities in each fork. Explore different approaches with full conversational context—each fork is a live session you can discuss, iterate on, and refine before committing to one direction.
17+
18+ ``` typescript
19+ // Exploring architectural approaches (not parallel implementations)
20+ session ({
21+ mode: " fork" ,
22+ agent: " plan" ,
23+ text: " Design this as a microservices architecture" ,
24+ })
25+
26+ session ({
27+ mode: " fork" ,
28+ agent: " plan" ,
29+ text: " Design this as a modular monolith" ,
30+ })
31+
32+ session ({
33+ mode: " fork" ,
34+ agent: " plan" ,
35+ text: " Design this as a serverless architecture" ,
36+ })
37+
38+ // Switch between sessions to discuss trade-offs, iterate on each approach
39+ // before committing to one architecture
40+ ```
41+
42+ ``` mermaid
43+ graph TD
44+ A[Main Session] -->|Fork| B[Approach A: Microservices]
45+ A -->|Fork| C[Approach B: Modular Monolith]
46+ A -->|Fork| D[Approach C: Serverless]
47+
48+ B --> E[Compare Results]
49+ C --> E
50+ D --> E
51+ ```
52+
53+ ** Use Cases:**
54+
55+ - Exploring alternative architectural approaches
56+ - Comparing different design patterns
57+ - "What if" scenario analysis before committing
58+ - Risk-free experimentation with full conversational context
59+
60+ ** Note:** Fork works best for design/architectural exploration, not parallel implementations of the same system.
61+
62+ ---
63+
1464### 🤝 ** COLLABORATE** — Turn-Based Agent Discussion
1565
1666Agents work together in the same conversation, passing the torch back and forth. Perfect for complex problems requiring multiple perspectives.
1767
1868``` typescript
69+ // Agent implements, then hands to review agent
70+ session ({
71+ mode: " message" ,
72+ agent: " review" ,
73+ text: " Review this authentication implementation" ,
74+ })
75+
76+ // Or research hands to plan
1977session ({
2078 mode: " message" ,
2179 agent: " plan" ,
22- text: " Should we use microservices here? " ,
80+ text: " Design our rate limiting based on this research " ,
2381})
24- // Plan agent reviews architecture and responds
25- // Can pass back to build agent for implementation
2682```
2783
2884``` mermaid
2985sequenceDiagram
3086 participant Build as Build Agent
3187 participant User as Session
32- participant Plan as Plan Agent
88+ participant Review as Review Agent
3389
3490 Build->>User: "Implemented feature X"
35- Note over Build: Tool: session(mode: "message", agent: "plan ")
91+ Note over Build: Tool: session(mode: "message", agent: "review ")
3692 Build->>Build: Finishes turn
37- User->>Plan : "Implemented feature X "
38- Plan ->>User: "Let me review that..."
39- Note over Plan: Reviews and provides feedback
40- Plan ->>Build: Passes back via session tool
93+ User->>Review : "Review this implementation "
94+ Review ->>User: "Let me review that..."
95+ Note over Review: Analyzes and provides feedback
96+ Review ->>Build: Can pass back via session tool
4197```
4298
4399** Use Cases:**
44100
45- - Complex problem-solving requiring multiple viewpoints
46- - Code review workflows (build → plan → build)
47- - Architecture discussions (plan ↔ researcher )
101+ - Code review workflows (build → review → build)
102+ - Research handoffs (researcher → plan → build)
103+ - Architecture discussions (plan ↔ build )
48104- Iterative refinement across agents
49105
106+ ** Note:** ⚠️ Not recommended when agents use different providers (e.g., Claude + GPT-4). Tested primarily with Sonnet 4.5 across agents.
107+
50108---
51109
52110### 🎯 ** HANDOFF** — Clean Phase Transitions
@@ -122,48 +180,6 @@ sequenceDiagram
122180
123181---
124182
125- ### 🔀 ** PARALLELIZE** — Explore Multiple Approaches
126-
127- Branch into independent sessions to try different solutions. Full primary agent capabilities in each fork.
128-
129- ``` typescript
130- // Try approach A
131- session ({
132- mode: " fork" ,
133- agent: " build" ,
134- text: " Implement using Redux" ,
135- })
136-
137- // Try approach B
138- session ({
139- mode: " fork" ,
140- agent: " build" ,
141- text: " Implement using Context API" ,
142- })
143-
144- // Compare results, pick the best
145- ```
146-
147- ``` mermaid
148- graph TD
149- A[Main Session] -->|Fork| B[Approach A: Redux]
150- A -->|Fork| C[Approach B: Context API]
151- A -->|Fork| D[Approach C: Zustand]
152-
153- B --> E[Compare Results]
154- C --> E
155- D --> E
156- ```
157-
158- ** Use Cases:**
159-
160- - Exploring alternative solutions
161- - Comparing different approaches
162- - "What if" scenario analysis
163- - Risk-free experimentation with full agent capabilities
164-
165- ---
166-
167183## Installation
168184
169185** Requirements:** OpenCode ≥ 0.15.18
@@ -204,6 +220,24 @@ rm -rf ~/.cache/opencode && opencode
204220
205221---
206222
223+ ## ⚠️ Important Usage Notes
224+
225+ ** Agents won't use this automatically:**
226+ - Mention the tool in your ` /command ` or conversation when you want agents to use it
227+ - Agents need explicit instruction to leverage session management
228+
229+ ** Enable per-agent, not globally:**
230+ - Turn the tool off globally in your config
231+ - Enable it only for specific primary agents (build, plan, researcher, etc.)
232+ - This prevents sub-agents from accidentally using it (unless your workflow requires it)
233+
234+ ** Message mode with mixed providers:**
235+ - ⚠️ Not recommended when agents use different providers (e.g., Claude + GPT-4)
236+ - Tested primarily with Sonnet 4.5 across agents
237+ - If you try mixed providers, please report your experience
238+
239+ ---
240+
207241## Usage
208242
209243### Basic Syntax
@@ -238,25 +272,19 @@ Use Tab in OpenCode to see all available agents.
238272### Example 1: Code Review Workflow
239273
240274``` typescript
241- // Build agent implements
275+ // Build agent implements, then hands to review
242276session ({
243277 mode: " message" ,
244- agent: " build " ,
245- text: " Implemented the user authentication system " ,
278+ agent: " review " ,
279+ text: " Review this authentication implementation for security issues " ,
246280})
247281
248- // Build passes to plan for review
282+ // Review agent provides feedback, build can address
283+ // Or research → plan handoff
249284session ({
250285 mode: " message" ,
251286 agent: " plan" ,
252- text: " Review the authentication implementation for security issues" ,
253- })
254-
255- // Plan provides feedback, passes back to build
256- session ({
257- mode: " message" ,
258- agent: " build" ,
259- text: " Address the CSRF vulnerability mentioned above" ,
287+ text: " Design our rate limiting system based on this research" ,
260288})
261289```
262290
@@ -303,34 +331,32 @@ session({
303331// User: Review the overall architecture we've built so far
304332```
305333
306- ### Example 4: Parallel Approach Exploration
334+ ### Example 4: Parallel Architectural Exploration
307335
308336``` typescript
309- // Current session: discussing database choice
337+ // Exploring architectural approaches before committing
310338
311- // Fork A: Try PostgreSQL approach
312339session ({
313340 mode: " fork" ,
314- agent: " build " ,
315- text: " Implement data layer using PostgreSQL with Prisma " ,
341+ agent: " plan " ,
342+ text: " Design this as a microservices architecture " ,
316343})
317344
318- // Fork B: Try MongoDB approach
319345session ({
320346 mode: " fork" ,
321- agent: " build " ,
322- text: " Implement data layer using MongoDB with Mongoose " ,
347+ agent: " plan " ,
348+ text: " Design this as a modular monolith " ,
323349})
324350
325- // Fork C: Try serverless approach
326351session ({
327352 mode: " fork" ,
328- agent: " build " ,
329- text: " Implement data layer using DynamoDB " ,
353+ agent: " plan " ,
354+ text: " Design this as a serverless architecture " ,
330355})
331356
332- // Each fork explores independently with full context
333- // Compare results using <leader>l to switch between sessions
357+ // Switch between sessions (<leader>l) to discuss trade-offs with each approach
358+ // Iterate on designs, then commit to one architecture
359+ // Note: Fork works best for design exploration, not parallel implementations
334360```
335361
336362---
0 commit comments