Repository navigation
fix(coordinator): persist agent results immediately after read_agent #684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -845,22 +845,35 @@ prompt: | | |||||
| (2) "Server Error Retry Loop" — context overflow after fan-out. Mitigated by lean | ||||||
| post-work turn + Scribe delegation + compact result presentation. --> | ||||||
|
|
||||||
| **⚡ Keep the post-work turn LEAN.** Coordinator's job: (1) present compact results, (2) spawn Scribe. That's ALL. No orchestration logs, no decision consolidation, no heavy file I/O. | ||||||
| **⚡ Keep the post-work turn LEAN.** Coordinator's job: (1) persist results, (2) present compact results, (3) spawn Scribe. That's ALL. No decision consolidation, no heavy file I/O beyond the mandatory persistence write in step 2. | ||||||
|
|
||||||
| **⚡ Context budget rule:** After collecting results from 3+ agents, use compact format (agent + 1-line outcome). Full details go in orchestration log via Scribe. | ||||||
|
|
||||||
| After each batch of agent work: | ||||||
|
|
||||||
| 1. **Collect results** via `read_agent` (wait: true, timeout: 300). | ||||||
|
|
||||||
| 2. **Silent success detection** — when `read_agent` returns empty/no response: | ||||||
| 2. **Persist results immediately** — `read_agent` data expires within ~2-3 minutes. Write each agent's result to `.squad/orchestration-log/{timestamp}-{agent-name}.md` **BEFORE** any other processing (presenting results, spawning Scribe, etc.). Create the directory if it doesn't exist. Use ISO 8601 UTC timestamp (e.g. `20260401T1423Z`). Format: | ||||||
| ```markdown | ||||||
| # {Agent Name} — {ISO 8601 UTC timestamp} | ||||||
| ## Task | ||||||
| {what was asked} | ||||||
| ## Result | ||||||
| {agent output summary} | ||||||
| ## Files Modified | ||||||
| {list of files the agent created or changed, or "None detected"} | ||||||
| ``` | ||||||
| This is the ONE exception to "no file I/O" — it is mandatory because results are unrecoverable once expired. | ||||||
|
Comment on lines
+856
to
+866
|
||||||
|
|
||||||
| 3. **Silent success detection** — when `read_agent` returns empty/no response: | ||||||
| - Check `.squad/orchestration-log/` for a file the agent may have written directly during its run. | ||||||
|
Comment on lines
+856
to
+869
|
||||||
| - Check filesystem: history.md modified? New decision inbox files? Output files created? | ||||||
| - Files found → `"⚠️ {Name} completed (files verified) but response lost."` Treat as DONE. | ||||||
| - No files → `"❌ {Name} failed — no work product."` Consider re-spawn. | ||||||
|
|
||||||
| 3. **Show compact results:** `{emoji} {Name} — {1-line summary of what they did}` | ||||||
| 4. **Show compact results:** `{emoji} {Name} — {1-line summary of what they did}` | ||||||
|
|
||||||
| 4. **Spawn Scribe** (background, never wait). Only if agents ran or inbox has files: | ||||||
| 5. **Spawn Scribe** (background, never wait). Only if agents ran or inbox has files: | ||||||
|
|
||||||
| ``` | ||||||
| agent_type: "general-purpose" | ||||||
|
|
@@ -878,7 +891,7 @@ prompt: | | |||||
| 0. PRE-CHECK: Stat decisions.md size and count inbox/ files. Record measurements. | ||||||
| 1. DECISIONS ARCHIVE [HARD GATE]: If decisions.md >= 20480 bytes, archive entries older than 30 days NOW. If >= 51200 bytes, archive entries older than 7 days. Do not skip this step. | ||||||
| 2. DECISION INBOX: Merge .squad/decisions/inbox/ → decisions.md, delete inbox files. Deduplicate. | ||||||
| 3. ORCHESTRATION LOG: Write .squad/orchestration-log/{timestamp}-{agent}.md per agent. Use ISO 8601 UTC timestamp. | ||||||
| 3. ORCHESTRATION LOG: Enrich .squad/orchestration-log/{timestamp}-{agent}.md files written by coordinator in step 2. Add detail from agent history if available. Write new entries for any agents not yet logged. Use ISO 8601 UTC timestamp. | ||||||
|
||||||
| 3. ORCHESTRATION LOG: Enrich .squad/orchestration-log/{timestamp}-{agent}.md files written by coordinator in step 2. Add detail from agent history if available. Write new entries for any agents not yet logged. Use ISO 8601 UTC timestamp. | |
| 3. ORCHESTRATION LOG: Enrich .squad/orchestration-log/{timestamp}-{agent-name}.md files written by coordinator in step 2, where `agent-name` is the spawned agent `name` (cast id), lowercased and made filename-safe. Add detail from agent history if available. Write new entries for any agents not yet logged. Use ISO 8601 UTC timestamp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Template parity: these edits were applied to mirror copies, but the canonical template
.squad-templates/squad.agent.mdstill has the old “After Agent Work” steps. The repo’s template-sync tests enforce byte-for-byte equality from.squad-templates/totemplates/,packages/*/templates/, and.github/agents/(seetest/template-sync.test.ts:4-6,118-141), so this PR will fail CI and/or get reverted the next timenode scripts/sync-templates.mjsruns. Please apply the change to.squad-templates/squad.agent.mdand re-run the sync script so all mirrors match.