Dashboard › opencode-lore › Distillation
753b9ca6-a184-4d98-b785-c29c02708ea5["lore_tm_v1_7t70OwxVHnsF-eL5urJHL7AH-aUgmw4vP4NXXsbLfs4","lore_tm_v1_PsIhXAQwWMdqzEpux6vArr2qc0kQyEaXXM-TO36roH8","lore_tm_v1_3vFs9jOQT_OVsLEhjiPMQ18qOTXNCoMWXF3Ojqwgcmk","lore_tm_v1_1OiVu_Oewd-elsMApetv9r-oKbTl_Xc59svBiDrImuw","lore_tm_v1_cxqr-NjP_4Fjz7RuFd5XpKPnKUmysJNzlbVCdzHdMic","lore_tm_v1_1rrThGTb3u_8UhJzItBxmNqAlxvEqnkgxX2ZV7tV60g","lore_tm_v1_awO4ZVqRp-5sAKLEwSFMcUCQjhf-EdbhucLcfAxbLyA"]
Date: Sep 16, 2026
packages/gateway/test/openai-responses-stream.test.ts was modified to import makeResponsesAccState and add extensive Responses streaming terminal/error-path coverage."validates and forwards a provider failure terminal" invokes streamResponsesPassthrough() with a response.failed SSE terminal whose response has status: "failed" and error { type: "server_error", message: "provider failed" }; it expects exactly one forwarded event: response.failed, preserved "provider failed" text, and records the completion outcome through outcomes.undefined, so it “never masquerades” as a real zero-write in analytics or cost tracking. In packages/gateway/src/pipeline.ts, cacheCreationInputTokens maps directly from prompt_tokens_details.cache_write_tokens.packages/gateway/src/pipeline.ts function accumulateResponsesNonStreamJSON() starts at line 12665. It filters item_reference entries from replayable output, rejects missing or duplicate response item/tool identities, normalizes output_text and refusal parts into text blocks, parses function_call.arguments, maps incomplete content_filter responses to stopReason: "content_filter" and other incomplete responses to "max_tokens", and changes an otherwise "end_turn" response containing tool use to "tool_use".accumulateResponsesNonStreamJSON() reads cache details from usage.input_tokens_details, falling back to usage.prompt_tokens_details for OpenAI-compatible providers; it computes disjoint inputTokens through disjointOpenAIInputTokens() and preserves cached_tokens and cache_write_tokens as cacheReadInputTokens and cacheCreationInputTokens.recordCacheUsage is pure session-state bookkeeping and “never touches the span.” The gen_ai.chat span is deliberately ended before recordCacheUsage() so extraction preserves the original ordering and an exception in recordCacheUsage() cannot leak an unfinished span.packages/gateway/src/pipeline.ts track cold-cache turns in a rolling 20-turn sessionState.coldCacheWindow; a turn is cold when cacheReadInputTokens === 0 and cacheCreationInputTokens > 0.recordCacheUsage() receives cache creation tokens, cache-read tokens, input tokens, sessionState.sessionID, turnWasIdleResume, and bustCause. Idle-resume rewarms and prefix-rewrite busts caused by Lore meta-distillation are excluded from user-context-growth-based consecutive-bust judgments.accountConversationUsage() starts at packages/gateway/src/pipeline.ts:13115; it converts GatewayUsage fields into Anthropic-style fields, calls setSentryCacheContext(), emits a "conversation" cost metric through emitCostMetric(), records cost through recordConversationCost(), and returns usageForSentry.packages/gateway/src/pipeline.ts: sanitizedUpstreamErrorResponse() at line 12047, preserveUpstreamErrorResponse() at line 12121, preservation call at line 15631, sanitization call at line 15816, and foreground completion with sanitization at line 18318.