feat(hooks): send session_id on hook searches for server-side injection dedup#124
Conversation
…on dedup UserPromptSubmit and PreToolUse searches now pass the Claude Code session_id to /api/search, so the reflexio backend skips rules it already returned to this session and backfills next-best matches — repeated hook searches stop re-injecting the same rules. Documented the dedup behavior and the post-compaction limitation in ARCHITECTURE.md.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughAdds an optional ChangesPer-session injection dedup
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Hook searches now pass the Claude Code
session_idto reflexio's unified/api/search, opting into the backend's session-scoped result dedup (ReflexioAI/reflexio#310): the server skips rules it already returned to this session and backfills next-best matches. A turn with ten tool calls injects each rule once instead of ten times, cutting repeated context injection without any client-side state.Works with any backend: older reflexio versions simply ignore the field (today it is metering-only metadata), so this can merge and ship independently — dedup activates once the backend side is deployed/vendored.
Changes
reflexio_adapter.py—search_allacceptssession_id(defaultNone) and forwards it onclient.search(...).context_inject.py—emit_contextpasses the hook payload's session id intosearch_all, covering both UserPromptSubmit and PreToolUse injection paths.ARCHITECTURE.md— documents the per-session injection dedup and the post-compaction limitation (samesession_idafter compaction means rules that fell out of context are not re-injected for the rest of that session).No vendored-client change needed —
client.searchalready accepts and forwardssession_id. No client-side filtering; the server owns dedup, and{session_id}.injected.jsonlremains citation-resolution-only.Test Plan
session_idforwarded when provided, defaults toNonewhen omittedsession_idtosearch_alltests/test_adapter.py+tests/test_events.pypass; ruff cleanSummary by CodeRabbit
New Features
Bug Fixes