Skip to content

refactor: remove read-time temporal enrichment from distillation prefix#129

Merged
BYK merged 4 commits intomainfrom
refactor/remove-read-time-temporal-enrichment
May 6, 2026
Merged

refactor: remove read-time temporal enrichment from distillation prefix#129
BYK merged 4 commits intomainfrom
refactor/remove-read-time-temporal-enrichment

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 6, 2026

Summary

  • Remove 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 time
  • Simplify distilledPrefix() and distilledPrefixCached() to pass distillations directly to formatDistillations() without temporal annotation mapping
  • Fix pre-existing test failures in embedding (cross-test data leaks) and temporal (stale data from prior runs)

What's preserved

  • Write-time temporal info (Layer A): HH:MM timestamps, Date: headers, inline date resolution ("last week""(meaning Jun 10, 2025)") — high value, computed once at distillation time
  • Segment detection & recall (Layer C): detectSegments() time-gap splitting, recall recency RRF bias — clear value, operates outside prompt pipeline

Why

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).

BYK added 4 commits May 6, 2026 12:42
…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
@BYK BYK enabled auto-merge (squash) May 6, 2026 14:07
@BYK BYK merged commit e2cdc3b into main May 6, 2026
1 check passed
@BYK BYK deleted the refactor/remove-read-time-temporal-enrichment branch May 6, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant