plugins/hooks/reflection/reflection

Reflection hook — background memory consolidation. Fires after N user turns. Spawns a background process that replays the conversation with a restricted tool list (memory only) and asks the model to consolidate learnings into the memory store.

Best-effort: errors are logged, never surfaced to the user. The background process opens its own DB connection so it doesn’t share state with the main conversation loop.

Values

pub fn should_reflect(
  turn_count: Int,
  turn_interval: Int,
) -> Bool

Check whether Reflection should fire based on the current turn count.

pub fn spawn_review(
  client: completions.Client,
  persona: String,
  history: List(completions.Message),
  user_key: String,
) -> Nil

Spawn a background process that reviews the conversation and consolidates memories. Returns immediately — the review runs asynchronously.

Search Document