Repository navigation
feat: track context window utilization - #2064
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c8ae7013-1eb9-4f99-8762-ea407e3633f3
🏗️ Architectural Review
Automated architectural review — informational only. |
🟠 Impact Analysis — PR #2064Risk tier: 🟠 HIGH 📊 Summary
🎯 Risk Factors
📦 Modules Affecteddocs (3 files)
root (1 file)
squad-cli (3 files)
squad-sdk (7 files)
tests (7 files)
|
🛫 PR Readiness Check
PR Scope: 📦🔧 Mixed (product + infrastructure)
|
| Status | Check | Details |
|---|---|---|
| ❌ | Single commit | 2 commits — consider squashing before review |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | Changeset file found |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ✅ | Copilot threads resolved | No Copilot review threads |
| ❌ | CI passing | 3 check(s) still running |
Files Changed (21 files, +1085 −21)
| File | +/− |
|---|---|
.changeset/1718-context-utilization.md |
+6 −0 |
docs/src/content/docs/reference/cli.md |
+1 −0 |
docs/src/content/docs/reference/config.md |
+1 −0 |
docs/src/content/docs/reference/sdk.md |
+22 −1 |
packages/squad-cli/src/cli/commands/watch/agent-spawn.ts |
+97 −4 |
packages/squad-cli/src/cli/commands/watch/capabilities/execute.ts |
+96 −7 |
packages/squad-cli/src/cli/shell/index.ts |
+91 −5 |
packages/squad-sdk/src/adapter/client.ts |
+1 −0 |
packages/squad-sdk/src/index.ts |
+1 −0 |
packages/squad-sdk/src/runtime/context-utilization.ts |
+161 −0 |
packages/squad-sdk/src/runtime/event-bus.ts |
+2 −1 |
packages/squad-sdk/src/runtime/event-payloads.ts |
+16 −0 |
packages/squad-sdk/src/runtime/otel-metrics.ts |
+36 −0 |
packages/squad-sdk/src/runtime/streaming.ts |
+113 −1 |
test/cli/watch-agent-spawn.test.ts |
+106 −1 |
test/cli/watch-capabilities.test.ts |
+90 −0 |
test/event-bus.test.ts |
+23 −0 |
test/otel-metrics.test.ts |
+32 −0 |
test/repl-streaming.test.ts |
+11 −0 |
test/session-adapter.test.ts |
+32 −0 |
test/streaming.test.ts |
+147 −1 |
Total: +1085 −21
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
|
👋 Friendly nudge — this PR has had no activity for 7 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
What
Measure per-session context-window utilization from exact Copilot runtime events, with a token-based estimate when exact data is unavailable, and surface threshold warnings and observability.
Why
Squad can select a context tier but previously had no gauge showing how much of the context window was occupied. This change makes context pressure measurable so routing and escalation decisions can be evaluated before exhaustion.
Closes #1718
How
session.usage_infosamples and estimated fallback utilization per session.context:utilizationruntime events and thesquad.context.utilizationOpenTelemetry gauge.StreamingPipeline.squad watchsummaries.Validation
npm run build -w @bradygaster/squad-sdknpm run build -w @bradygaster/squad-clinpm run lintchecks .squad/ralph-instructions.md inside teamRoot; all context-utilization tests pass.Quick Check
.changeset/1718-context-utilization.mdPR Readiness Checklist
Branch & Commit
devBuild & Test
npm run lintpassesnpm run lint:eslintpassesChangeset
Docs
Breaking Changes
None.
Waivers
None.