Dashboard › opencode › Distillation
403fced1-956d-4ccb-aa06-27d067eacb6c["lore_tm_v1_A-J2nLf5FVPCvLILXtlB9V4JEt817wt3rBabxKGjOGw","lore_tm_v1_LHDhHTFE2AlZSLVBc-sdZ0psAAxq4oGp0VHkltSywYA","lore_tm_v1_Ijqgcu3KlsP0yVXwacuIzkq72NgUCt1g2JZyD-5mBus","lore_tm_v1_RvOSu2-v4S0sEvB4ps-vKVKUW7T9YuXDooFtGlwqJLM","lore_tm_v1_v0-GDKLX4QVEyocBSQiLwbXu0pJ-4Obq8XkaI60Vf9o"]
Date: Sep 16, 2026
packages/core/src/session/runner/llm.ts defines SessionRunner.run with required sessionID, force, executionID, and ownerID, plus optional recoveryInputID; the execution claim is { sessionID, executionID, ownerID }, and recovery mode is selected when recoveryInputID !== undefined.SessionRunner.run suppresses normal pending-input checks during recovery: hasSteer and hasQueue become false; otherwise it checks "steer" before "queue". It returns without running only when not recovering, not forced, and neither input kind is pending.SessionRunner.run calls failInterruptedTools(input.sessionID, claim). Initial promotion is { recoveryInputID } during recovery, otherwise "steer", "queue", or undefined according to pending work.SessionRunner.run loops continuation steps beginning at step = 1, calls runTurn(input.sessionID, input.executionID, promotion, step, input.ownerID), advances to result.step + 1, and switches ordinary follow-up promotion to "steer". After continuation finishes, ordinary execution drains pending "queue" inputs; recovery runs exactly one outer cycle and does not drain later steer or queue inputs.SessionRunner location node depends on EventV2.node, llmClient, AgentV2.node, ToolRegistry.node, SessionRunnerModel.node, SessionStore.node, Location.node, SystemContextRegistry.node, SkillGuidance.node, ReferenceGuidance.node, Config.node, Snapshot.node, and Database.node.packages/core/src/session/runner/publish-llm-event.ts validates "tool-error" events by defecting on an error before its call (Tool error before call: ${event.id}), a changed tool name (Tool error name changed for ${event.id}: ${tool.name} -> ${event.name}), or duplicate settlement (Duplicate tool error: ${event.id}); a valid error publishes SessionEvent.Tool.Failed with error: { type: "unknown", message: event.message }, provider execution state, and optional provider metadata.packages/core/src/session/runner/publish-llm-event.ts, "step-finish" flushes buffered publication, sets assistantActive = false, defects on a second finish with Duplicate step finish, and stores { finish: event.reason, tokens: tokens(event.usage) }; "provider-error" sets providerFailed = true and calls failAssistant(event.message), while "finish" itself performs no action.createLLMEventPublisher exposes publish, flush, failAssistant, interruptAssistant, failUnsettledTools, hasActiveAssistant, hasAssistantStarted, hasProviderError, stepSettlement, startAssistant, and assistantMessageID.packages/core/src/session/compaction.ts uses exact defaults DEFAULT_BUFFER = 20_000, DEFAULT_KEEP_TOKENS = 8_000, TOOL_OUTPUT_MAX_CHARS = 2_000, and SUMMARY_OUTPUT_TOKENS = 4_096; document compaction settings override auto, buffer, and keep.tokens, with defaults { auto: true, buffer: DEFAULT_BUFFER, tokens: DEFAULT_KEEP_TOKENS }.## Objective; ## Important Details; ## Work State with ### Completed, ### Active, and ### Blocked; ## Next Move with ordered items 1. and 2.; and ## Relevant Files. Rules require every section, terse bullets, preservation of exact paths/symbols/commands/errors/URLs/identifiers, and no mention that context was compacted.packages/core/src/session/compaction.ts combine <prior-summary> with newer <conversation> content; carry forward objectives, constraints, directives, decisions, and parallel workstreams unless finished and no longer needed; prefer newer conflicting information; add new progress and context; move finished work from Active to Completed; update resolved blockers while retaining continuation details; and refresh Objective and Next Move.[User], [Assistant], [Assistant reasoning], [Assistant tool call], [Tool result], [Tool error], [System update], [Synthetic context], and [Shell]. Tool and shell output beyond 2_000 characters is truncated to the first 2_000 characters plus \n[truncated]; attachments serialize with MIME type and optional name."compaction" messages, serializes remaining entries, and walks backward to retain recent conversation within the configured token budget; it returns the older portion as head and retained context as recent.buildPrompt creates a fresh anchored summary when no previous summary exists. When one exists, it supplies both <conversation> and <prior-summary> plus SUMMARY_UPDATE_INSTRUCTIONS, because the prior summary will be discarded after replacement.SessionCompaction.compactAfterOverflow returns false when model context is absent/nonpositive, no usable older context exists, or the summary prompt cannot fit within context - summaryOutput. summaryOutput is capped at exactly 4_096 tokens and otherwise uses the configured/requested output allowance.SessionEvent.Compaction.Started with reason: "auto" and a newly created SessionMessage.ID, streams an LLM request with the same model and HTTP settings, no tools, and generation.maxTokens = summaryOutput, then publishes SessionEvent.Compaction.Ended with the accumulated summary and selected.recent.LLM.Error, emits any provider error, or produces only blank text. beforeStream runs immediately before the summary stream; eventCommit is attached to SessionEvent.Compaction.Started, while commit is attached to SessionEvent.Compaction.Ended.SessionCompaction.compactIfNeeded is disabled when config.auto is false and skips compaction when estimated request size is at most context - Math.max(output, config.buffer); otherwise it delegates to compactAfterOverflow.