Dashboard › opencode › Distillation
94a42d32-9beb-4613-a86b-e69d81a41ed6["lore_tm_v1_5RXpK74XffWcI_95qV7zcO37uBNA1nOhK2Jar56-X8E","lore_tm_v1_EZtsVU8itm3oBWXyCVoUonTDMmRNW-RMPydvNDTYQBw","lore_tm_v1_uSeXkVfHGeS9T7aO7l5ZTBvfDSJ_9P-eNqIbXnVHXw8","lore_tm_v1_nGJwO4GXKHDc-EuASkxIdg76SDhsB8Unh0R7fBUK4Lg","lore_tm_v1_Lulq10_E6qSpLs4OeqSARy2WpqL4sEfhMX4xFBMarvc","lore_tm_v1_GQpO-Sa6cp_6xwQDGWyDX5GMJJN12bL6QiL7guJHblQ","lore_tm_v1_WNNSEWNMDV7ZoKrCdxslHo5wZcieDO-rAF8qLdi94o8","lore_tm_v1_8uYLgKcFqSrSSZQTez0b2DYVYvyzEcUZLGc3qT5JRVM"]
Date: Sep 14, 2026
/home/byk/Code/opencode/packages/core/src/database/migration/20260603141458_session_input_inbox.ts:21 creates session_input_session_pending_seq_idx on (session_id,promoted_seq,seq); /home/byk/Code/opencode/packages/core/src/database/migration/20260603160727_jittery_ezekiel_stane.ts:8,13 drops that index and creates session_input_session_pending_delivery_seq_idx on (session_id,promoted_seq,delivery,seq); /home/byk/Code/opencode/packages/core/src/database/migration/20260604172448_event_sourced_session_input.ts:37 recreates the latter index using admitted_seq instead of seq./home/byk/Code/opencode/packages/core/src/database/migration/20260604172448_event_sourced_session_input.ts, ID 20260604172448_event_sourced_session_input. It deletes all rows from session_input, session_message, event, event_sequence, nulls session.workspace_id, and deletes workspace; makes event_aggregate_seq_idx unique on (aggregate_id,seq) and session_message_session_seq_idx unique on (session_id,seq); rebuilds session_input with columns id, session_id, prompt, delivery, admitted_seq, nullable promoted_seq, and time_created, plus cascading FK fk_session_input_session_id_session_id_fk; then creates session_input_session_pending_delivery_seq_idx on (session_id,promoted_seq,delivery,admitted_seq), unique session_input_session_admitted_seq_idx on (session_id,admitted_seq), and unique session_input_session_promoted_seq_idx on (session_id,promoted_seq)./home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/handlers/tui.ts:14 maps session_interrupt to "session.interrupt"; /home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/groups/session.ts:324,337 uses identifiers "session.prompt" and "session.prompt_async"./home/byk/Code/opencode/packages/opencode/src/session/status.ts stores SessionStatusEvent.Info in a process-local Map<SessionID, Info>, publishes Event.Status, and removes idle sessions; /home/byk/Code/opencode/packages/opencode/src/session/prompt.ts sets "busy" while running and handles tool states "pending", "running", "completed", and "error"; /home/byk/Code/opencode/packages/opencode/src/session/processor.ts initializes tool state as { status: "pending", input: {}, raw: "" } and later sets Session status to "idle" or "busy"; /home/byk/Code/opencode/packages/opencode/src/session/run-state.ts also maps execution lifecycle to "busy"/"idle"./home/byk/Code/opencode/packages/llm/src/route/executor.ts treats HTTP 429, 503, 504, and 529 as explicitly retryable, parses retry-after-ms and retry-after, attaches retryAfterMs, caps provider-specified delays with MAX_DELAY_MS, and recursively retries only when error.retryable is true and retries remain. /home/byk/Code/opencode/packages/llm/src/protocols/shared.ts drops the provider SDK’s Retry control event via Stream.catchTag("Retry", () => Stream.empty). /home/byk/Code/opencode/packages/llm/src/protocols/bedrock-converse.ts emits retryable provider errors and marks throttling exceptions retryable.LLMClient.stream(request) for incremental LLMEvents; LLMClient.generate(request) to collect the same events into an LLMResponse; and LLMClient.prepare<Body>(request) to compile through the route pipeline without sending. The optional Body generic only narrows .body to the route-native type—for example, prepare<OpenAIChatBody>(...) returns PreparedRequestOf<OpenAIChatBody>—without changing the runtime body.Protocol in src/route/protocol.ts owns body.from, body.schema, stream.event, and the stream.step state machine; examples are OpenAIChat.protocol, OpenAIResponses.protocol, AnthropicMessages.protocol, Gemini.protocol, and BedrockConverse.protocol. 2. Endpoint in src/route/endpoint.ts owns host, path, and query, commonly through Endpoint.path("/chat/completions", { baseURL }), with callback paths for typed values such as Endpoint.path(({ body }) => `/model/${body.modelId}/converse-stream`). 3. Auth in src/route/auth.ts owns per-request transport authentication through mechanisms such as Auth.bearer(apiKey), Auth.header(name, apiKey), or request-signing functions for Bedrock SigV4, future Vertex IAM, and Azure AAD. 4. Framing in src/route/framing.ts converts bytes to frames, sharing Framing.sse while Bedrock uses typed AWS event-stream framing.OpenAIChat.protocol verbatim; each deployment is intended to be a 5–15-line Route.make(...) call rather than a 300–400-line route clone, allowing protocol fixes to propagate to all consumers in one commit.joinText(parts) joins TextPart-like .text values with newlines; parseToolInput(route, name, raw) Schema-decodes tool arguments, treats empty input as {}, and uses the canonical error "Invalid JSON input for \<route>` tool call `<name>`"; parseJson(route, raw, message)performs generic JSON-via-Schema decoding;eventError(route, message, ...)constructs typedInvalidProviderOutput; validateWith(decoder)maps Schema failures toInvalidRequest; and matchToolChoice(provider, choice, branches)lowersLLMRequest["toolChoice"]` through provider-specific branches.claude-opus-4-8) through Anthropic Messages supports native chronological system messages; other routes/models intentionally lower updates in place into ordinary user-compatible text using a stable escaped representation.Array.from(events).find(LLMEvent.is.toolCall) and dispatch it via ToolRuntime.dispatch(tools, call) only when !call.providerExecuted; callers then persist the call and dispatched.result and explicitly construct the next request. Recoverable tool errors must be ToolFailure; the runtime emits a tool-error followed by a tool-result with type: "error", while non-ToolFailure errors are defects that fail the stream.request.tools without a runtime entry, and ensure the matching route lowers them to provider-native form. Anthropic currently accepts web_search, code_execution, and web_fetch; OpenAI Responses accepts its documented hosted tool names.Effect.fn("Provider.fromRequest") for request-body construction entrypoints; use Effect.fn(...) for event handlers that yield effects; keep synchronous handlers as plain functions returning StepResult for dispatcher lifting through Effect.succeed(...); make intentional provider differences explicit in helper names/comments; and assess whether files can be compared side-by-side with openai-chat.ts, provider quirks are isolated and tested, unsupported common content is rejected at the protocol boundary, stream parsing emits stable common events without leaking provider event order, and toolChoice: "none" is visibly intentional./home/byk/Code/opencode/packages/core/src/session/message-updater.ts projects tool lifecycle states from "pending" through "running" to "completed" or "error"; /home/byk/Code/opencode/packages/core/src/session/runner/to-llm-message.ts handles pending input and completed/error results; /home/byk/Code/opencode/packages/core/src/session/runner/llm.ts still lists durable busy, retrying, idle, interrupted, and terminal-failure status handling as TODOs; /home/byk/Code/opencode/packages/core/src/session/run-coordinator.ts and /home/byk/Code/opencode/packages/core/src/session/execution.ts both describe execution as starting while idle or joining the active execution./home/byk/Code/opencode/AGENTS.md:153 specifies that SessionV2.prompt(...) durably admits one session_input before advisory SessionExecution.wake(sessionID), except resume: false is admit-only; the serialized runner promotes admitted inputs at safe boundaries.Step; its durable record covers only the model-visible span. Never use “provider turn” or bare “turn” for one call because turn is reserved for the future assistant-turn unit spanning all Steps from prompt promotion until the Session would become idle.llm.stream(request) call per Step and reload projected history before durable continuation; it must not bridge through legacy SessionPrompt.loop(...) or delegate orchestration to an in-memory tool loop.SessionRunCoordinator joins explicit same-Session resumes, coalesces prompt wakeups, and permits different Sessions to run concurrently. Advisory wakes drain only eligible durable inbox rows; post-crash continuation requires a separate explicit design before retrying provider work. A drain has no durable identity or transcript boundary.queue input remains pending until the Session would otherwise become idle; promote one queued input at that boundary, reevaluate continuation, then consider another. Any newly promoted user input resets the selected agent’s Step allowance, while a batch of steers resets it once.opencode.json require a user-controlled quit/restart because file watchers and tool.reload() replay active transforms but do not rerun plugin setup; never restart production services automatically.HOME, XDG config/data/state/cache trees, explicit LORE_DB_PATH, an explicit gateway URL, and unused loopback ports; afterward remove credentials and stop only disposable processes. Full isolation was chosen over gateway discovery/default paths because discovery can reuse the live gateway and dataDir() may migrate durable state; invoke the exact Node executable because isolated HOME can leave Volta without a runtime.apiKey sugar and explicit auth must remain mutually exclusive through ProviderAuthOption. Always resolve keys with AuthOptions.bearer(options, "<PROVIDER>_API_KEY"); direct environment reads are rejected because they bypass explicit auth overrides and turn missing credentials into runtime crashes rather than typed Authentication errors..jj/, especially colocated .jj and .git, must use Jujutsu exclusively for mutations; Git is allowed only for read-only inspection or capabilities unavailable in Jujutsu. Avoid interactive flags, supply explicit -m messages for describe/commit operations, prefer stable change IDs over commit hashes, and never rebase or describe immutable commits.jj rebase, jj new, or jj squash, run jj st, resolve conflict markers manually, and verify with both jj st and jj log; use jj undo or operation-log recovery when needed.