main
md 89 lines 5.26 KB
Rendered Raw
1 ---
2 name: "client-compatibility"
3 description: "Platform detection and adaptive spawning for CLI vs VS Code vs other surfaces"
4 domain: "orchestration"
5 confidence: "high"
6 source: "extracted"
7 ---
8
9 ## Context
10
11 Squad runs on multiple Copilot surfaces (CLI, VS Code, JetBrains, GitHub.com). The coordinator must detect its platform and adapt spawning behavior accordingly. Different tools are available on different platforms, requiring conditional logic for agent spawning, SQL usage, and response timing.
12
13 ## Patterns
14
15 ### Platform Detection
16
17 Before spawning agents, determine the platform by checking available tools:
18
19 1. **CLI mode**`task` tool is available → full spawning control. Use `task` with `agent_type`, `mode`, `model`, `description`, `prompt` parameters. Collect results via `read_agent`.
20
21 2. **VS Code mode**`runSubagent` or `agent` tool is available → conditional behavior. Use `runSubagent` with the task prompt. Drop `agent_type`, `mode`, and `model` parameters. Multiple subagents in one turn run concurrently (equivalent to background mode). Results return automatically — no `read_agent` needed.
22
23 3. **Fallback mode** — neither `task` nor `runSubagent`/`agent` available → work inline. Do not apologize or explain the limitation. Execute the task directly.
24
25 If both `task` and `runSubagent` are available, prefer `task` (richer parameter surface).
26
27 ### VS Code Spawn Adaptations
28
29 When in VS Code mode, the coordinator changes behavior in these ways:
30
31 - **Spawning tool:** Use `runSubagent` instead of `task`. The prompt is the only required parameter — pass the full agent prompt (charter, identity, task, hygiene, response order) exactly as you would on CLI.
32 - **Parallelism:** Spawn ALL concurrent agents in a SINGLE turn. They run in parallel automatically. This replaces `mode: "background"` + `read_agent` polling.
33 - **Model selection:** Accept the session model. Do NOT attempt per-spawn model selection or fallback chains — they only work on CLI. In Phase 1, all subagents use whatever model the user selected in VS Code's model picker.
34 - **Scribe:** Cannot fire-and-forget. Batch Scribe as the LAST subagent in any parallel group. Scribe is light work (file ops only), so the blocking is tolerable.
35 - **Launch table:** Skip it. Results arrive with the response, not separately. By the time the coordinator speaks, the work is already done.
36 - **`read_agent`:** Skip entirely. Results return automatically when subagents complete.
37 - **`agent_type`:** Drop it. All VS Code subagents have full tool access by default. Subagents inherit the parent's tools.
38 - **`description`:** Drop it. The agent name is already in the prompt.
39 - **Prompt content:** Keep ALL prompt structure — charter, identity, task, hygiene, response order blocks are surface-independent.
40
41 ### Feature Degradation Table
42
43 | Feature | CLI | VS Code | Degradation |
44 |---------|-----|---------|-------------|
45 | Parallel fan-out | `mode: "background"` + `read_agent` | Multiple subagents in one turn | None — equivalent concurrency |
46 | Model selection | Per-spawn `model` param (4-layer hierarchy) | Session model only (Phase 1) | Accept session model, log intent |
47 | Scribe fire-and-forget | Background, never read | Sync, must wait | Batch with last parallel group |
48 | Launch table UX | Show table → results later | Skip table → results with response | UX only — results are correct |
49 | SQL tool | Available | Not available | Avoid SQL in cross-platform code paths |
50 | Response order bug | Critical workaround | Possibly necessary (unverified) | Keep the block — harmless if unnecessary |
51
52 ### SQL Tool Caveat
53
54 The `sql` tool is **CLI-only**. It does not exist on VS Code, JetBrains, or GitHub.com. Any coordinator logic or agent workflow that depends on SQL (todo tracking, batch processing, session state) will silently fail on non-CLI surfaces. Cross-platform code paths must not depend on SQL. Use filesystem-based state (`.squad/` files) for anything that must work everywhere.
55
56 ## Examples
57
58 **Example 1: CLI parallel spawn**
59 ```typescript
60 // Coordinator detects task tool available → CLI mode
61 task({ agent_type: "general-purpose", mode: "background", model: "claude-sonnet-4.5", ... })
62 task({ agent_type: "general-purpose", mode: "background", model: "claude-haiku-4.5", ... })
63 // Later: read_agent for both
64 ```
65
66 **Example 2: VS Code parallel spawn**
67 ```typescript
68 // Coordinator detects runSubagent available → VS Code mode
69 runSubagent({ prompt: "...Fenster charter + task..." })
70 runSubagent({ prompt: "...Hockney charter + task..." })
71 runSubagent({ prompt: "...Scribe charter + task..." }) // Last in group
72 // Results return automatically, no read_agent
73 ```
74
75 **Example 3: Fallback mode**
76 ```typescript
77 // Neither task nor runSubagent available → work inline
78 // Coordinator executes the task directly without spawning
79 ```
80
81 ## Anti-Patterns
82
83 - ❌ Using SQL tool in cross-platform workflows (breaks on VS Code/JetBrains/GitHub.com)
84 - ❌ Attempting per-spawn model selection on VS Code (Phase 1 — only session model works)
85 - ❌ Fire-and-forget Scribe on VS Code (must batch as last subagent)
86 - ❌ Showing launch table on VS Code (results already inline)
87 - ❌ Apologizing or explaining platform limitations to the user
88 - ❌ Using `task` when only `runSubagent` is available
89 - ❌ Dropping prompt structure (charter/identity/task) on non-CLI platforms