You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Evaluate Redis for tracking memories injected since the last compaction #3784
#3764 stopped memory recall from injecting a memory that the replayed history already holds. In its review thread, @BYK proposed Redis for this state. We agreed to evaluate that proposal in a follow-up.
Current design
UserPromptContext.loadHistory() reads the plugin's turn_context events in the current History version, and the time of the newest compaction or handoff.
turn_context is saved in the same append as its Turn's messages. A compaction starts a new History version, so the set resets with no hook.
Since 78d151201, the History version filter runs in SQL (loadCurrentEventsOfType). Rows of older versions are not read.
Proposal
A Redis set of injected memory ids, keyed by Conversation id, reset on each compaction.
Also record the version and archival state of each memory, so a new version of a memory can be injected again.
What to measure before we decide
Production loadHistory latency: p50, p95 and max.
Rows read per call.
The share of recall Turns that call it.
Then compare those numbers with a Redis round trip. If Redis wins, the design must also cover:
Decision: keep the turn_context event log. No Redis.
Production data for plugin.prompt_history.load, 2026-11-21 to 2026-11-24 (5,511 reads):
Latency: p50 22 ms, p95 113 ms, max 1,287 ms.
Rows read: p50 0, p95 21, max 59.
41% of memory userPrompt hooks ran recall and read prompt history. The other 59% have no request text and skip recall.
The read runs in parallel with the recall embedding call, and recall's vector search takes seconds after both finish. So the read adds almost nothing to recall latency. Redis would save time that is already hidden.
Latency barely grows with rows. A read with 0 rows already takes about 19 ms at p50, so database round trips set the floor.
The one real cost was an unused third query that runs in sequence when the Conversation has a compaction or handoff. #4231 removes it.
Activity
feat(plugins): Time prompt history reads and count the rows they read (…
sentry-junior commentedon Nov 24, 2026
Decision: keep the
turn_contextevent log. No Redis.Production data for
plugin.prompt_history.load, 2026-11-21 to 2026-11-24 (5,511 reads):userPrompthooks ran recall and read prompt history. The other 59% have no request text and skip recall.The one real cost was an unused third query that runs in sequence when the Conversation has a compaction or handoff. #4231 removes it.
perf(plugins): Read the newest History replacement with one query (#4231