Dashboard › opencode › Distillation
4793a6fc-08de-40de-a146-96ea0e8aa927["lore_tm_v1_Pa4YuFRmS-CJsmTgHlT0-75UoyGHGpLdLEohxvulfVs","lore_tm_v1_EPQgZtqi0JmUCl3Sbg1WdKBHd0q9G3o1AiODCk_yEKI"]
x-lore-agent matches a primary conversation agent, the request is βalways a normal turn.βx-lore-agent matches a meta/housekeeping agent, the request is βalways passthrough.β/home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts defines detectCompactionRequest(req) with ordered fallback detection: 1. any case-insensitive COMPACTION_SYSTEM_PATTERNS match in the system prompt returns { detected: true, reason: "system-prompt", pattern }; 2. when req.tools.length === 0, a last-user-message match from COMPACTION_USER_PATTERNS returns reason "user-keywords"; 3. a <template> tag plus at least MIN_TEMPLATE_SECTION_MATCHES section matches returns reason "template-sections" with matchCount; otherwise it returns { detected: false }.isCompactionRequest(req) is the boolean wrapper around detectCompactionRequest(req).detected; the detailed detection result is intended for pipeline logging./home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts defines PREVIOUS_SUMMARY_RE = /<previous-summary>\n(.*?)\n<\/previous-summary>/s; extractPreviousSummary(req) applies it to lastUserText(req) and returns the captured content or undefined./home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts exports LORE_AGENT_HEADER = "x-lore-agent".x-lore-agent classification uses PRIMARY_AGENTS = new Set(["coder", "code"]) for normal turns and META_AGENTS = new Set(["title", "summary", "summarize", "categorize", "label", "classify"]) for passthrough meta/housekeeping requests; matching is case-insensitive via agentHeader.toLowerCase(), while unknown agents fall through to heuristics.isMetaRequest(req) treats compaction separately by immediately returning false when isCompactionRequest(req) is true.isMetaRequest(req) uses two layers: 1. authoritative explicit x-lore-agent; 2. heuristic scoring for all clients. It returns true when a request should bypass Lore processing and is intentionally biased toward false negatives rather than incorrectly skipping a real conversation turn./home/byk/Code/opencode-lore-v2/packages/gateway/src/compaction.ts are: SCORE_FEW_TOOLS = 3 for tools β€2, SCORE_FEW_MESSAGES = 3 for messages β€2, SCORE_SHORT_SYSTEM = 2 for system prompts under 500 characters, SCORE_LOW_MAX_TOKENS = 3 for maxTokens β€300, and SCORE_META_KEYWORDS = 2; META_SCORE_THRESHOLD = 8, preserving backward compatibility because the prior 3-check conjunction scored 3+3+2 = 8.META_MAX_TOOLS = 2, META_MAX_MESSAGES = 2, META_MAX_SYSTEM_LENGTH = 500, META_MAX_TOKENS = 300, and META_KEYWORD_SYSTEM_LENGTH = 2000; keyword scanning is limited to shorter prompts to avoid false positives on large prompts.META_KEYWORDS contains, in order: 1. "generate a title", 2. "generate a short title", 3. "title for the conversation", 4. "title for this conversation", 5. "summarize this conversation", 6. "summarize the conversation", 7. "conversation summary", 8. "categorize", 9. "classify this", 10. "label this".