refactor: remove read-time temporal enrichment from distillation prefix#129
Merged
refactor: remove read-time temporal enrichment from distillation prefix#129
Conversation
…d workers Enable cache_control annotations on requests forwarded to Anthropic, targeting two high-value cache slots: 1. System prompt caching: explicit breakpoint with 5m TTL for conversation turns (frequent enough for refresh) and 1h TTL for worker calls (bursts separated by minutes of thinking). 2. Conversation prefix caching: breakpoint on the last message block so Anthropic caches the byte-stable prefix between turns. At layer 0 (~100% prefix stability) this yields ~78% savings; at layer 1 (~85-93% stability) ~67% savings over 10-turn stretches. Title/summary passthrough requests are explicitly excluded — their unique-per-call content would produce 1.25x write cost with zero reads. Projected savings: ~50-1200/month on current Lore API spend.
Move knowledge entries from the lore-managed section in AGENTS.md to a dedicated .lore.md file. AGENTS.md now contains only a pointer to .lore.md, reducing system prompt bloat and merge conflicts. - Add exportLoreFile/importLoreFile/shouldImportLoreFile/loreFileExists - exportToFile writes pointer in AGENTS.md + entries in .lore.md - All adapters (OpenCode, Gateway, Pi) prefer .lore.md with AGENTS.md fallback for backward compat - Commit reminder gated on knowledge.enabled, mentions both files - Automatic migration: first idle export after update creates .lore.md - 59 tests covering new functions, migration, and round-trip stability
Remove addRelativeTimeToObservations() and helpers (formatRelativeTime,
parseDateFromContent, expandInlineEstimatedDates) — ~130 lines of untested
code that added low-value relative annotations ('3 days ago', gap markers,
'likely already happened') at render time.
Write-time temporal info (HH:MM timestamps, Date headers, inline date
resolution) and segment detection time-gap splitting are preserved — these
provide the actual value for sequence reasoning in evals.
Also fix pre-existing test failures:
- embedding: vectorSearch beforeEach now cleans all knowledge rows to
prevent cross-test data leaks
- temporal: add beforeAll cleanup of stale data from prior test runs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
addRelativeTimeToObservations()and helpers (formatRelativeTime,parseDateFromContent,expandInlineEstimatedDates) — ~130 lines of untested, low-value code that added relative annotations ("3 days ago", gap markers, "likely already happened") at render timedistilledPrefix()anddistilledPrefixCached()to pass distillations directly toformatDistillations()without temporal annotation mappingWhat's preserved
Date:headers, inline date resolution ("last week"→"(meaning Jun 10, 2025)") — high value, computed once at distillation timedetectSegments()time-gap splitting, recall recency RRF bias — clear value, operates outside prompt pipelineWhy
Layer B (read-time enrichment) had zero test coverage, a latent inconsistency bug in the delta-append path (old rows keep stale relative annotations), and provided information the model can already compute from absolute dates + the current date in the system prompt. Removing it eliminates non-deterministic
new Date()calls from the prefix rendering pipeline.Tests
508 pass, 0 fail (was 503 pass, 5 fail before test fixes).