Dashboard › opencode › Distillation
5173f949-dded-4c7a-99bc-c9d0b92f87f9["lore_tm_v1_jV8dUVzuX1LXkTcYo-Uew8zDLC-1_LQ_4VrGHvA0oc8"]
x-lore-agent matches a primary agent, the request is always a normal turn; PRIMARY_AGENTS = new Set(["coder", "code"]) in /home/byk/Code/opencode-lore/packages/gateway/src/compaction.ts lines 377–380.x-lore-agent matches a meta/housekeeping agent, the request is always passthrough; META_AGENTS = new Set(["title", "summary", "summarize", "categorize", "label", "classify"]) in /home/byk/Code/opencode-lore/packages/gateway/src/compaction.ts lines 382–393./home/byk/Code/opencode-lore/packages/gateway/src/compaction.ts lines 395–413 define meta-request heuristic scoring: SCORE_FEW_TOOLS = 3 for tools ≤ META_MAX_TOOLS = 2; SCORE_FEW_MESSAGES = 3 for messages ≤ META_MAX_MESSAGES = 2; SCORE_SHORT_SYSTEM = 2 for system prompts shorter than META_MAX_SYSTEM_LENGTH = 500; SCORE_LOW_MAX_TOKENS = 3 for maxTokens ≤ META_MAX_TOKENS = 300; SCORE_META_KEYWORDS = 2; META_SCORE_THRESHOLD = 8; and keyword scanning is limited to META_KEYWORD_SYSTEM_LENGTH = 2000.META_SCORE_THRESHOLD = 8 preserves backward compatibility because the former 3-check conjunction scored 3+3+2 = 8; heuristic comments note real agents have 5+ tools, meta requests are generally single-shot with ≤2 messages, and real prompts are typically 2K–50K characters.META_KEYWORDS in /home/byk/Code/opencode-lore/packages/gateway/src/compaction.ts lines 415–426 contains, in order: "generate a title", "generate a short title", "title for the conversation", "title for this conversation", "summarize this conversation", "summarize the conversation", "conversation summary", "categorize", "classify this", and "label this".isMetaRequest(req: GatewayRequest) uses two layers: (1) authoritative explicit x-lore-agent header classification for OpenCode, then (2) heuristic scoring for all clients using structural, token-budget, and keyword signals. It returns true to bypass Lore processing and is intentionally biased toward false negatives rather than incorrectly skipping a real conversation turn.isMetaRequest() first returns false for isCompactionRequest(req). It then reads req.rawHeaders[LORE_AGENT_HEADER], lowercases the value, returns false for PRIMARY_AGENTS, returns true for META_AGENTS, and sends unknown agent names through heuristic classification.extractPreviousSummary(req: GatewayRequest): string | undefined in /home/byk/Code/opencode-lore/packages/gateway/src/compaction.ts lines 361–367 applies PREVIOUS_SUMMARY_RE to lastUserText(req) and returns match?.[1] ?? undefined.