Skip to main content

Module context

Module context 

Source
Expand description

Context meter + handoff doc generator (Phase 12).

Sparrow needs a reliable view of “what is in my context right now” so that /compact and the PreCompact hook fire at the right moment, and so the UI can render a meter. This module is intentionally pure: no I/O at the type-level, no provider calls. Tests cover the math.

Structs§

ContextMeter
Character counts per category of input that contributes to the model context window. All five categories are tracked separately so a UI can show where the budget is going.
HandoffDoc
A durable handoff document captured at compaction time. It is what makes the next IA (or the same one on resume) productive without rereading the whole transcript.

Constants§

TOKENS_PER_CHAR
Conservative chars-per-token ratio (matches ContextManager).

Functions§

distill_transcript
Best-effort distillation of a transcript into decision/file/blocker lines. Pure function — caller owns the messages slice. Used by sparrow compact.