feat: Built-in Memory Reflection hook (periodic memory review prompt)
Idea
Add a built-in memory_reflection hook that injects a periodic prompt every N messages, reminding the agent to review recent conversation and update its memory file if needed.
Why
Agents with persistent memory (e.g. memory_system/MAINMEMORY.md) benefit greatly from periodic self-review — catching decisions, preferences, or error solutions that weren't explicitly written to memory at the time.
Currently this requires patching orchestrator/hooks.py and orchestrator/core.py manually after every upgrade.
Proposed config
"hooks": {
"memory_reflection": {
"enabled": true,
"every_n_messages": 10
}
}
Hook content (suggested)
## MEMORY REFLECTION
Review the last several messages in this conversation.
Check: were there any new decisions, corrections, error solutions, user preferences,
or important facts that you did NOT yet write to memory?
If yes — update memory now, silently.
If everything is already recorded — do nothing.
Notes
The hook infrastructure already exists (MessageHook, every_n_messages, registry in core.py). This would just be a new built-in hook wired to a config flag — minimal implementation effort.
Shipped in v0.16.0.
Added a memory_reflection config section that fires a periodic "memory review" turn at a configurable cadence (every_n_messages). Opt-in (default off) so existing setups don't suddenly start running extra turns. Implementation lives in MessageHookRegistry next to the existing hooks — easy to extend further later. Pairs nicely with the new pre-compaction flush (#77) and LLM-driven compaction (#80).