Dashboard › opencode › Distillation
84fd328c-b8b6-44e5-9acf-1acfef8b02e0["lore_tm_v1_XVTPCIa4Sg7yCvwR0858K7mifHJnMGuK4Q4JRL1iXJU","lore_tm_v1_wUN7AvDmc6nQnvUJE1VE_13c00og3uouAqWIRyQkWLo","lore_tm_v1_xfBhAEfWLD8tAwLiAw0_zjwtPIz0d1UB_D4dskEiMro"]
Date: Sep 17, 2026
/tmp/opencode/session-recovery-v21-review/packages/core/src/session/compaction.ts configures automatic context compaction with DEFAULT_BUFFER = 20_000, DEFAULT_KEEP_TOKENS = 8_000, TOOL_OUTPUT_MAX_CHARS = 2_000, and SUMMARY_OUTPUT_TOKENS = 4_096; document configuration can override compaction.auto, compaction.buffer, and compaction.keep.tokens.SessionCompaction summaries must preserve the ordered Markdown sections ## Objective, ## Important Details, ## Work State with ### Completed, ### Active, and ### Blocked, then ## Next Move with exactly 2 numbered entries, and ## Relevant Files. Instructions require terse bullets, all sections even when empty, and exact preservation of file paths, symbols, commands, error strings, URLs, and identifiers.SUMMARY_UPDATE_INSTRUCTIONS makes newer conversation content authoritative over <prior-summary>, carries forward unfinished objectives, constraints, directives, decisions, and parallel workstreams, moves finished work from Active to Completed, updates resolved blockers, and refreshes Objective and Next Move./tmp/opencode/session-recovery-v21-review/packages/core/src/session/compaction.ts serializes messages with explicit labels: [User], [Assistant], [Assistant reasoning], [Assistant tool call], [Tool result], [Tool error], [System update], [Synthetic context], and [Shell]. Tool and shell output exceeding 2,000 characters is truncated and suffixed with \n[truncated]; attachments become [Attached <mime>: <name-or-uri>].select(entries, tokens) excludes messages whose type is "compaction", serializes the remaining conversation, and walks backward from the newest content to retain a recent suffix within the configured token budget; it returns the older material as head and retained material as recent.buildPrompt() creates either a fresh anchored summary or an updated summary combining <conversation> with <prior-summary>; when updating, the prior summary’s stored recent content and newly selected head are supplied as context.compactIfNeeded() skips compaction when automatic compaction is disabled, the model context limit is absent/nonpositive, or estimated { system, messages, tools } usage does not exceed context - Math.max(output, config.buffer); otherwise it delegates to compactAfterOverflow().compactAfterOverflow() refuses compaction if no valid context limit exists, no selectable history exists, no older head exists without a prior compaction, or the summary prompt exceeds context - summaryOutput. Summary output is capped at 4,096 tokens via Math.min(output || SUMMARY_OUTPUT_TOKENS, SUMMARY_OUTPUT_TOKENS).SessionEvent.Compaction.Started and SessionEvent.Compaction.Ended with reason: "auto", stores generated summary text plus selected.recent, uses an LLM request with tools: [], and returns false if streaming raises LLM.Error, emits a provider error, or produces blank output.