fix: context overflow sentinel and coordinator size reduction#1035
Draft
obit91 wants to merge 5 commits intobradygaster:devfrom
Draft
fix: context overflow sentinel and coordinator size reduction#1035obit91 wants to merge 5 commits intobradygaster:devfrom
obit91 wants to merge 5 commits intobradygaster:devfrom
Conversation
When sessions grow long, the ~84KB squad.agent.md coordinator file can be silently dropped from context, causing Squad to degrade to a vanilla Copilot agent with no safety rails (no PRs, no branch protection, no agent routing). Solution 1 — Sentinel: Add a coordinator-presence check to copilot-instructions.md (always loaded, ~3KB). When the coordinator is missing, the agent warns loudly and refuses to work silently. Solution 2 — Size reduction: Extract detailed content from squad.agent.md into 5 on-demand reference files, reducing it from ~84KB to ~55KB (33% smaller). Extracted sections: model selection, client compatibility, spawn templates, after-agent-work steps, and worktree lifecycle. New template files: - model-selection-reference.md - client-compatibility-reference.md - spawn-reference.md - after-agent-reference.md - worktree-reference.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove hard-coded ~80KB size estimate from copilot-instructions.md sentinel (size will change over time, keep description generic) - Add ralph-reference.md to .squad-templates/ and TEMPLATE_MANIFEST (was referenced by squad.agent.md but missing from template distribution) - Replace hard-coded 'main' branch in worktree-reference.md with default branch detection via git symbolic-ref - Add cross-worktree safety warning to squad.agent.md inline (main-checkout strategy not safe for concurrent sessions) Closes bradygaster#1017 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add response mode exemplars back inline (Direct/Lightweight/Standard/Full) - Expand ralph-reference.md with full work-check cycle details (gh commands, categorization table, periodic check-in, watch mode, three layers, board format, integration with follow-up work) - Add cross-worktree considerations to worktree-reference.md (worktree-local vs main-checkout strategy details) - Restore cross-worktree safety guidance inline in squad.agent.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Per review feedback from @tamirdresher: semantic self-inspection ('do you see coordinator instructions?') is unreliable for LLMs. Replace with deterministic canary token approach: - Add <!-- SQUAD_COORDINATOR_CANARY_a8f3 --> at end of squad.agent.md - copilot-instructions.md checks for exact token string - Catches both missing coordinator AND truncation (token at EOF) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-only Content validation revealed that ralph-reference.md and casting-reference.md contained newly authored sections not present in the original squad.agent.md. ralph-reference.md: Removed Board Format state machine, Idle-Watch Mode, Activation Triggers, and Work-Check Termination sections (newly authored). Restored original Step 3 priority ordering bullet that was simplified. Kept only content that was inline in the original. casting-reference.md: Added note clarifying this is new specification material that fills a gap (the original referenced this file but never had the content inline). Universe table, selection algorithm, and JSON schemas are additive. Closes bradygaster#1017 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1017 — Squad coordinator silently drops in long sessions due to context overflow.
Problem
When sessions grow long, the ~84KB
squad.agent.mdcoordinator file can be silently dropped from<available_skills>due to context budget pressure. The session degrades to a vanilla Copilot agent with no safety rails and no warning — no agent routing, no PRs, no branch protection.Solution (two complementary fixes)
Canary token sentinel in
copilot-instructions.md— a deterministic<!-- SQUAD_COORDINATOR_CANARY_a8f3 -->token at the end ofsquad.agent.md. The always-loadedcopilot-instructions.mdchecks for this exact token. If missing (coordinator dropped or truncated), it warns loudly and refuses to proceed silently. This replaces the earlier semantic self-inspection approach per reviewer feedback.Size reduction of
squad.agent.mdfrom ~84KB → ~57KB (32% smaller) by extracting detailed reference content into on-demand files that agents load only when needed:after-agent-reference.md— post-work checklist, Scribe spawn templatecasting-reference.md— universe table, selection algorithm, state schemasclient-compatibility-reference.md— platform detection, VS Code adaptationsmodel-selection-reference.md— 4-layer model hierarchy, role mappingralph-reference.md— work-check cycle, idle-watch, board formatspawn-reference.md— full spawn template, lightweight templateworktree-reference.md— lifecycle management, dependency setupValidation
upstream/dev(unrelatedFSStorageProviderSDK export) — our changes are template-onlyupstream/dev(ec07f38)Review feedback addressed
Closes #1017