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(autoloop): auto-compact on context-budget threshold
Closes the last design-doc deferred item (§7.1). Each agent gets a /compact
dispatched when its contextPercent crosses the per-role threshold (Planner
80%, Coder 70%, Reviewer 70%) — uses Claude Code's built-in /compact slash
command with an agent-specific preservation hint, so session id is kept and
no manual memory-file dance is needed.
Implementation:
- dispatcher.maybeCompact(agent, name) in src/autoloop/dispatcher.ts —
reads getStatus(name).stats.contextPercent, fires compactSession()
when over threshold, 30s cooldown to prevent back-to-back fires
- per-agent compactSummaryFor() builds the /compact <hint> text:
Planner keeps plan/goal/user decisions; Coder keeps codebase
familiarity + attempted patches; Reviewer keeps fakery patterns +
recent metrics
- called at the end of deliverToPlanner / deliverToCoder /
deliverToReviewer (both happy path and clarification path for Coder,
both verdict and no-verdict path for Reviewer)
- new 'compact' SSE event on /autoloop/<id>/events, plumbed via
embedded-server's existing SSE relay
- ClaudeAgentDispatcherConfig.compactThresholds for per-run override
Dashboard: renders compact events inline in the relevant pane as
'[auto-compact <pct>% ≥ <threshold>% — /compact dispatched]' system entries.
501/501 tests pass; build/lint/format clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments