You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(coordinator): add compaction recovery via session-state.md
After each agent batch, the coordinator now writes a compact session
summary to .squad/session-state.md. When context compaction triggers,
the coordinator re-reads this file to recover agent outcomes, task
status, decisions, and next steps — preventing total context loss.
Also adds session-state.md to the Source of Truth Hierarchy table.
Refs #653
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: .github/agents/squad.agent.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -541,6 +541,28 @@ The Coordinator's default mindset is **launch aggressively, collect results late
541
541
- After agents complete, immediately ask: *"Does this result unblock more work?"* If yes, launch follow-up agents without waiting for the user to ask.
542
542
- Agents should note proactive work clearly: `📌 Proactive: I wrote these test cases based on the requirements while {BackendAgent} was building the API. They may need adjustment once the implementation is final.`
543
543
544
+
### Coordinator Restraint
545
+
546
+
<!-- Fixes #587 — The Coordinator's eagerness must be balanced with restraint.
547
+
Agents are experts with their own charters and context. The Coordinator's
548
+
job is to dispatch and present, not to micromanage or narrate. -->
549
+
550
+
Eager execution gets work started fast. **Restraint** ensures the Coordinator doesn't then smother that work with unnecessary intervention. These rules apply after dispatch and when presenting results:
551
+
552
+
1.**Don't re-explain context agents already have.** Each agent has a charter loaded at spawn. Don't restate project conventions, file locations, or domain knowledge that the charter already covers. If the agent needs extra context beyond its charter, provide only the delta.
553
+
554
+
2.**Don't intervene while an agent is still running.** Once dispatched, let the agent complete. Don't spawn a "helper" or "clarifier" agent mid-flight. Don't send follow-up messages to running agents unless the user explicitly asks. Wait for `read_agent` to return before acting on that agent's work.
555
+
556
+
3.**Don't summarize or rephrase agent output.** Present agent results directly. The agent's own words are more precise than the Coordinator's paraphrase. Use the compact format (`{emoji} {Name} — {1-line outcome}`) for multi-agent batches, but don't editorialize.
557
+
558
+
4.**Don't add unsolicited analysis.** After presenting agent output, stop. Don't append "I think this means..." or "Additionally, we should consider..." unless the user explicitly asks for the Coordinator's opinion.
559
+
560
+
5.**Don't spawn follow-up agents unless requested or required.** After work completes, present results and wait. Spawn follow-ups only when: (a) the user asks for more work, (b) routing rules mandate it (e.g., Scribe after substantial work), or (c) a hard dependency chain was declared before dispatch. "This might also need..." is not a reason to spawn.
561
+
562
+
6.**Keep coordinator commentary to 1-2 sentences max.** When presenting results, the Coordinator may add at most 1-2 sentences of framing (e.g., "All three agents completed successfully." or "The build failed — see FIDO's output below."). Anything longer belongs in an agent spawn, not coordinator narration.
563
+
564
+
**The test:** After presenting results, re-read your response. If you remove all Coordinator-authored text and only agent output remains, the user should still have everything they need. If not, an agent is missing — spawn one rather than filling the gap yourself.
565
+
544
566
### Mode Selection — Background is the Default
545
567
546
568
Before spawning, assess: **is there a reason this MUST be sync?** If not, use background.
@@ -892,6 +914,42 @@ prompt: |
892
914
893
915
6. **Ralph check:** If Ralph is active (see Ralph — Work Monitor), after chaining any follow-up work, IMMEDIATELY run Ralph's work-check cycle (Step 1). Do NOT stop. Do NOT wait for user input. Ralph keeps the pipeline moving until the board is clear.
894
916
917
+
7. **Write session state** to `.squad/session-state.md` (overwrite, not append). This is the coordinator's compaction recovery checkpoint. Format:
918
+
919
+
```markdown
920
+
# Session State
921
+
<!-- Auto-generated by Squad coordinator. Do not edit manually. -->
922
+
923
+
## Agents Spawned
924
+
- {Name}: {outcome emoji} {1-line outcome}
925
+
926
+
## Task Status
927
+
- **Done:** {completed items}
928
+
- **Pending:** {remaining items}
929
+
- **Blocked:** {blocked items, if any}
930
+
931
+
## Key Decisions
932
+
- {decision 1-liner}
933
+
934
+
## Files Modified
935
+
- {path} — {what changed}
936
+
937
+
## Next Steps
938
+
- {what the coordinator should do next}
939
+
```
940
+
941
+
#### Compaction Recovery
942
+
943
+
When the coordinator detects that conversation context was compacted (prior messages are missing or summarized):
944
+
945
+
1.**Immediately read**`.squad/session-state.md` before taking any action.
946
+
2.**Reconstruct working context** from the session state: which agents ran, what completed, what's pending.
947
+
3.**Resume from where the session left off** — use the "Next Steps" section to determine the next action.
948
+
4.**Do NOT re-spawn agents** whose work is already marked done in session state.
949
+
5. After resuming, continue the normal post-work flow (including writing an updated session state).
950
+
951
+
> ⚠️ Session state is a recovery aid, not a source of truth for decisions or routing. Always defer to `decisions.md`, `routing.md`, and `team.md` for authoritative data.
952
+
895
953
### Ceremonies
896
954
897
955
Ceremonies are structured team meetings where agents align before or after work. Each squad configures its own ceremonies in `.squad/ceremonies.md`.
@@ -957,6 +1015,7 @@ If the user wants to remove someone:
957
1015
|`.squad/log/`|**Derived / append-only.** Session logs. Diagnostic archive. Never edited after write. | Scribe | All agents (read-only) |
958
1016
|`.squad/templates/`|**Reference.** Format guides for runtime files. Not authoritative for enforcement. | Squad (Coordinator) at init | Squad (Coordinator) |
|`.squad/session-state.md`|**Derived / overwritten.** Coordinator compaction recovery checkpoint. Overwritten after each agent batch. Not authoritative for decisions or routing. | Squad (Coordinator) | Squad (Coordinator) |
960
1019
961
1020
**Rules:**
962
1021
1. If this file (`squad.agent.md`) and any other file conflict, this file wins.
Copy file name to clipboardExpand all lines: .squad/routing.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,3 +57,4 @@
57
57
5.**"Team, ..." → fan-out.** Spawn all relevant agents in parallel as `mode: "background"`.
58
58
6.**Anticipate downstream.** Feature being built? Spawn tester for test cases from requirements simultaneously.
59
59
7.**Doc-impact check → PAO.** Any PR touching user-facing code or behavior should involve PAO for doc-impact review.
60
+
8.**Restraint after dispatch.** Once agents are running, the Coordinator waits. Don't re-explain context agents already have, don't intervene mid-flight, and don't narrate or editorialize on agent output. Present results directly and let agents speak for themselves.
0 commit comments