Expand description
Context control ledger.
Pure typed model of the context working set: candidate/selected items, model context limits, token budgets, and diagnostics.
Structs§
- Context
Budget - Token budget derived from
ModelContextLimits. - Context
Counts - Visibility counts for a
ContextLedger. - Context
Diagnostic - A diagnostic about context or model-limit state.
- Context
Item - A single context source considered for the working set.
- Context
Ledger - The context ledger: all candidate/selected items, the budget, and diagnostics for a turn.
- Live
Model Metadata - Live provider metadata translated into the neutral limits shape at the adapter boundary.
- Model
Context Limits - Provider-neutral model context limits.
- Model
Limit Override - User-supplied model limit override parsed from
[model_limits."provider/model-id"].
Enums§
- Context
Item Kind - Kind of context a
ContextItemrepresents. - Context
Visibility - Inclusion status of a
ContextItemin the current working set. - Diagnostic
Severity - Severity of a
ContextDiagnostic. - Model
Limit Confidence - Confidence in a
ModelContextLimitsvalue. - Model
Limit Source - Provenance of a
ModelContextLimitsvalue.
Constants§
- AUTO_
COMPACTION_ RATIO - Fraction of the available input budget above which auto-compaction may trigger after normal eviction and summary candidates.
- FALLBACK_
CONTEXT_ WINDOW - Conservative fallback context window when no model metadata is available.
- FALLBACK_
MAX_ COMPLETION_ TOKENS - Conservative fallback max completion tokens when no metadata is available.
- FALLBACK_
RECOMMENDED_ COMPLETION_ TOKENS - Conservative fallback recommended completion tokens when no metadata is available.
- PROVIDER_
OVERHEAD_ TOKENS - Reserved provider overhead (tokens) subtracted from the input budget.
- TARGET_
BUDGET_ RATIO - Fraction of the available input budget that selection targets.
- TOKEN_
BYTES_ DIVISOR - Conservative bytes-per-token divisor used until provider tokenizers exist.
- TOKEN_
ITEM_ OVERHEAD - Fixed overhead added to every item’s token estimate.
Functions§
- estimate_
tokens - Conservative token estimate:
ceil(utf8_bytes / 3) + 16. - item_
id_ for_ path - Generate a stable context item id for a file-backed source.
- item_
id_ for_ session_ range - Generate a stable context item id for a transcript/session source range.
- render_
ledger_ summary - Render a compact user-visible ledger summary line.
- render_
model_ dashboard - Render a compact model-visible context dashboard.