Expand description
Conversation compaction — turn a long message history into a structured summary.
Structs§
- Applied
Compaction - What the engine applied. Pure data — the frontend adopts these fields; all persistence already happened (successor-first save ordering).
- Compaction
Disclosure - The pre-dispatch disclosure summary (spec §9.4): provider, model, and approximate disclosure every frontend surfaces BEFORE remote compaction.
- Compaction
Outcome - Typed result of a summarization call (spec §9.3): the summary text plus the provenance metadata the transition persists.
- Compaction
Transition - Frontend-supplied context for one transition.
- Disclosure
Policy - Disclosure policy for one compaction (spec §9.4): where summarization runs and which content classes are withheld from the request.
- Rendered
Compaction Input - The policy-filtered summarization input, computable WITHOUT any network operation — this is what disclosure previews and the dispatch path share, so what the user inspects is exactly what would be sent.
Enums§
- Compaction
Policy - How a successful compaction is applied to session state (spec §9.2).
- Transition
Failpoint - Deterministic failure-injection points inside the linked-successor transition (I2, CP-12 review). The enum is always available so rollback code can name the steps; the injection machinery is test-gated.
Constants§
- COMPACTION_
SYSTEM_ PROMPT - System prompt used for the compaction API call. Instructs the model to summarize, not continue the conversation.
- LOCAL_
SUMMARY_ MODEL - Model label for the local extractive summarizer.
Functions§
- apply_
compaction - Task 30 (spec §9.2): the ONE engine operation applying a successful compaction for every frontend. Handles successor-vs-in-place policy, session id and chain advancement, accounting, typed provenance, pending events and queued messages, hooks, save ordering, and rollback: nothing is returned (and no caller state changes) unless the new state was persisted, so a failed save leaves the prior session intact.
- compact_
conversation - Serialize the in-memory API message history into a policy-filtered
transcript and produce the typed
CompactionOutcome. Remote mode asks the configured summarizer model; local-only mode (spec §9.4) derives the summary in-process and constructs NO network request. Called by/compactand every auto-compaction path. - preview_
compaction_ disclosure - Compute the disclosure summary for the next compaction WITHOUT any network operation. Uses the same rendering as the dispatch path, so the preview is exact for content classes and approximate only in bytes.
- provider_
label_ for_ model - Provider label for a model, derived from its resolved route (bare model names route to Anthropic). Unroutable models are labeled honestly.
- render_
compaction_ input - Render the summarization request under a disclosure policy. Pure — no
network, no provider dependence. Sentinel-tested per class: excluded
classes must not appear in
prompt_text. - transitions_
applied - Read the process-wide applied-transition count (see
[
TRANSITIONS_APPLIED]). Test/diagnostic seam: harnesses assert the counter moves exactly once per transition and not at all for summarization without a transition.