On-Demand Compaction
Unlike Beads' nightly cron, Recall compaction is ON-DEMAND.
When to Compact
- Before ops handoff - ensure clean context for new ops
- Before spawning agents - give them focused context
- After long sessions - prevent memory bloat
- On explicit request - recall.compact(force=True)
Compaction Flow
- Query Session for AI state older than threshold (default 7 days)
- Group related items (same project, same session)
- Call Haiku API: 'Summarize this in 3-5 sentences'
- Store compacted summary in Recall archive
- Mark originals as compacted (don't delete)
API Call (Haiku)
response = anthropic.messages.create(
model='claude-3-5-haiku-20241022',
max_tokens=500,
messages=[{
'role': 'user',
'content': f'Summarize this AI working context in 3-5 sentences:\n{content}'
}]
)
Cost Estimate
- Haiku: ~$0.25/M input tokens, ~$1.25/M output tokens
- Typical session: ~2000 tokens input, ~200 tokens output
- Cost per compaction: < $0.001