Skip to content

feat(memory): Match half-typed words and cache query embeddings in Cmd+K search - #4119

Merged
BYK merged 1 commit into
mainfrom
feat/memory-typed-search-prefix
Nov 23, 2026
Merged

BYK merged 1 commit into
mainfrom
feat/memory-typed-search-prefix

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #4106, part of #4095.

Half-typed words. Typed memory search added :* to english stems, so a half-typed inflected word missed its memory: runn did not match "running" (stem run) until the word was complete. Typed search now adds a simple word-prefix leg, the same match that Inbox items and Automations use. It reads a new partial GIN index on active rows (0166_memory_prefix_index, created CONCURRENTLY). Its rank is fused with the english and vector legs in the shared ranking, so it adds a parallel statement and no serial round. The english leg goes back to recall's exact stem match. Agent recall does not change.

Embedding calls.

  • The vector leg runs only when the typed text has 3 or more characters. Shorter text matches by words alone.
  • The query embedding is cached in the state adapter for 10 minutes, keyed by model and normalized text. Typing the same text again makes no model call.
  • Each embedding call adds its cost to a daily junior_stats counter (search / embedding_cost_micro_usd, one row per model). A search has no Conversation to bill. One short query costs a fraction of a micro-USD, so plain rounding would store 0 every time. The new usdToMicroUsdUnbiased in db/micro-usd.ts rounds up with the chance of the fraction, so the daily total in whole micro-USD stays right on average. The write runs beside the vector query.

via @BYK.

--

View Session [Sentry]

…d+K search

Typed memory search added `:*` to `english` stems, so a half-typed
inflected word missed its memory until the word was complete. A new
`simple` word-prefix leg, read from its own partial GIN index on active
rows, now runs beside the `english` and vector legs and is fused with
them. Agent recall does not change.

The vector leg now runs only for 3 or more characters, reuses the
embedding of the same text for 10 minutes, and adds each embedding
call's cost to a daily `junior_stats` counter in whole micro-USD.

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested a review from BYK November 23, 2026 19:35
@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 23, 2026 7:35pm UTC

Request Review

@BYK
BYK enabled auto-merge (squash) November 23, 2026 19:37
@github-actions

Copy link
Copy Markdown
Contributor

1 screenshot change — 1 changed · 0 added · 0 removed

Review screenshots in Frameshift

System Cache Warming Refill · Desktop
System Cache Warming Refill · Desktop
Changed

@BYK
BYK merged commit dc3264f into main Nov 23, 2026
58 checks passed
@BYK
BYK deleted the feat/memory-typed-search-prefix branch November 23, 2026 19:48

This branch was successfully deployed

1 active deployment
Preview – junior-docs — fbfef05a Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant