Ray's Knowledge Base
Unlock

With bm25-bert the failure hook injects only when the failure quotes the lesson's error

DecisionVerified 1 Oct 2026Holds project: rkb
Decision. The context, the choice, why, and the options that were turned down.

Context#

Cosine thresholds gave wrong injections on the user's real logged failures: 12 right and 6 wrong with the old rule. The eval had 36 positives, so the numbers are hints.

Decision#

For bm25-bert, the failed-command hook injects the top lesson only if the failure text contains a backticked string of 2 or more words, as whole words, that the lesson quotes. Cosine only orders the results. Prompt recall still uses relevance 0.55 and margin 0.08. Jev and plain bm25 keep their old rules. literal_gate = false under [hooks] in kb.toml turns it off.

Why#

  • In an offline port on the 36 failures, the gate gave 16 right and 1 wrong. On the 23 failures that came after their lesson, it gave 9 right and 1 wrong, against 5 right and 6 wrong for the hand rule.
  • Through rkb eval --replay, injections fell from 23 to 18 without queries and from 34 to 20 with them.
  • Recall on later failures is about 39%, and it misses failures with other wording.

Rejected options#

  • Inject when either rule fires: 21 right but 7 wrong.
  • Suppress by similarity to past no-lesson failures, a calibrator and a fine-tuned embedder: no gain.

Also found by searching

  • why did the failure hook not inject a lesson with bm25-bert
  • when does the rkb failure hook inject the top lesson
  • literal_gate setting in kb.toml hooks
  • how does rkb decide to inject a lesson after a failed command