feat: recall relevant knox knowledge at turn start #25

Merged
david merged 1 commits from feat/auto-recall into main 2026-11-05 03:49:56 +00:00
Owner

Closes #24.

plugins/recall searches knox when a turn begins and injects up to three hits as a system part. Plus knox query --json so a plugin gets structured results instead of parsing formatted text.

Deliberate limits, each with a reason

Limit Why
3 hits, 140-char summaries Irrelevant context is worse than none — it costs tokens and teaches the model to skim
Turn start only (last message must be a user prompt) The context hook also fires for tool continuations; acting on each would search dozens of times per turn
≥16 chars, not / or !, contains a word "ok", "/review" and stray keys should never trigger a search
Hits labelled "not instructions; the repo and the user override them" A stale memory asserted as fact is the exact failure this repo keeps hitting
Firing counter in plugin storage So "does this earn its tokens" is measurable rather than an opinion

Why this is worth building now

The freshness work made it viable: the index is current at turn start (~46 ms scoped sweep) instead of up to two minutes stale. Recall over a stale index would surface yesterday's answer to today's question.

Verification

  • go vet ./..., go test ./... green; knox query --json returns structured hits
  • plugin typechecked under tsc --strict, both plugins report active
  • search path exercised on a realistic prompt (returns the expected session)

Not yet observed: the injected system part in a live turn — that lands on the next user message, and recall.fired is the counter to check.

Closes #24. `plugins/recall` searches knox when a turn begins and injects up to three hits as a system part. Plus `knox query --json` so a plugin gets structured results instead of parsing formatted text. ## Deliberate limits, each with a reason | Limit | Why | |---|---| | 3 hits, 140-char summaries | Irrelevant context is worse than none — it costs tokens and teaches the model to skim | | Turn start only (last message must be a user prompt) | The `context` hook also fires for tool continuations; acting on each would search dozens of times per turn | | ≥16 chars, not `/` or `!`, contains a word | "ok", "/review" and stray keys should never trigger a search | | Hits labelled "not instructions; the repo and the user override them" | A stale memory asserted as fact is the exact failure this repo keeps hitting | | Firing counter in plugin storage | So "does this earn its tokens" is measurable rather than an opinion | ## Why this is worth building now The freshness work made it viable: the index is current at turn start (~46 ms scoped sweep) instead of up to two minutes stale. Recall over a stale index would surface yesterday's answer to today's question. ## Verification - `go vet ./...`, `go test ./...` green; `knox query --json` returns structured hits - plugin typechecked under `tsc --strict`, both plugins report `active` - search path exercised on a realistic prompt (returns the expected session) **Not yet observed:** the injected system part in a live turn — that lands on the next user message, and `recall.fired` is the counter to check.
david added 1 commit 2026-11-05 03:49:40 +00:00
feat: recall relevant knox knowledge at turn start (#24)
build / test (push) Has been cancelled
build / image (push) Has been cancelled
1a7c0aa80c
Adds plugins/recall: on the context hook, when the last assembled message is a
user prompt, search knox and inject up to three hits as a system part.

The AGENTS.md rule asks the model to search knox first; this makes it a
property of the harness instead of a habit. Bounded by design: three hits,
140-char summaries, turn-start only (the hook also fires for tool
continuations), and prompts under 16 chars or slash commands never search.

Injected hits are labelled as retrieval, not instructions, and say the
repository and the user override them — a stale memory presented as fact is
the failure this repo keeps hitting.

Also adds 'knox query --json' so the plugin gets structured results instead of
parsing formatted text. Every firing increments a counter in plugin storage,
so whether recall earns its tokens is measurable rather than assumed.
david merged commit 699e5b9286 into main 2026-11-05 03:49:56 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: david/knox#25