Infinite Sessions
Context rotation is how Groove gives you effectively infinite AI coding sessions. Instead of letting sessions degrade, Groove detects the decline, captures full state, and respawns with perfect context.
The Degradation Problem
Every AI coding session follows the same arc. Early on, the model is sharp — fast, accurate, focused. As the context window fills, quality drops. You start seeing:
- Hallucinated file paths and function names
- Circular refactors — changing code back and forth without progress
- Lost direction — forgetting the original task
- Increased tool failures and retries
Most developers restart manually when they notice this. By then, significant tokens have been wasted, and the new session loses all the context the old one built up.
How Infinite Sessions Work
Groove automates the entire cycle:
- Monitor — track degradation signals from the running agent
- Detect — identify when quality has dropped below the adaptive threshold
- Capture — trigger the Journalist to snapshot current state
- Rotate — kill the old session, spawn a fresh one with a handoff brief
- Continue — the new session picks up exactly where the old one left off
The agent never loses context. The session is effectively infinite.
Degradation Signals
Groove tracks five categories of degradation in a sliding 50-event classifier window:
| Signal | What It Measures |
|---|---|
| Error count and trend | Rising error rates indicate context confusion |
| File churn | Repeatedly modifying the same files signals circular work |
| Repetitions | Duplicate tool calls or repeated explanations |
| Tool failures | Failed reads, writes, or commands |
| Scope violations | Touching files outside the agent's assigned scope |
These signals are combined into a session score from 0 to 100, where 100 is a perfectly healthy session.
Adaptive Thresholds
Rotation thresholds are not static. They adapt per provider and per role:
- Each provider/role combination maintains its own threshold
- After each rotation, the threshold is adjusted: +2% if the session scored well (rotation was premature), -5% if it scored poorly (rotation was late)
- Thresholds are persisted to disk and survive daemon restarts
- Over time, thresholds converge to the optimal point for each combination
Convergence
After enough rotations, thresholds stabilize. Groove will rotate Claude Code backend agents at a different point than Gemini CLI frontend agents, because each combination degrades differently.
The Handoff Brief
When rotation triggers, the new agent receives a handoff brief containing:
- Agent identity — role, scope, original task
- Recent tool calls — what the agent was doing in its final moments
- Results — files created and modified, outcomes achieved
- Project map — the latest Journalist synthesis (up to 10K characters)
- Original task — the instruction that started the session
The new agent reads this brief and continues seamlessly.
Natural Pause Detection
Groove is aware of each model's context limits (Opus 1M, Sonnet/Haiku 200K) and factors them into rotation timing. It will not rotate an agent mid-action — it waits for a natural pause before triggering, preventing corruption from interrupted operations.
Manual Rotation
You can always trigger rotation manually from the GUI or CLI with groove rotate <id>.
