feat(conversational): session-aware conversational search (Sprint 3)#3
Merged
svalench merged 2 commits intoMay 8, 2026
Merged
Conversation
added 2 commits
May 8, 2026 07:04
Adds Sprint 3: an optional conversational search layer on top of the
existing Searcher / LangGraph pipeline.
Highlights:
* New CONVERSATIONAL settings section with safe defaults (disabled).
* New memory/ subpackage:
- BaseMemoryBackend contract + ConversationEvent dataclass.
- InMemoryBackend (process-local, thread-safe, bounded deque).
- DjangoCacheBackend (works with any Django cache, including Redis
via django-redis, without taking a hard Redis dependency).
- build_memory_backend factory with short aliases (inmemory, cache,
redis) and dotted-path support.
* New langgraph_conversation module with the conversational graph:
load_context -> interpret_followup -> maybe_clarify ->
[execute_search] -> store_context, plus an in-tree fallback runner.
* Follow-up interpretation is conservative on purpose: 'more',
'similar', 'only X' patterns reuse the previous turn; otherwise the
query is left untouched. Ambiguous short follow-ups produce a
structured clarification_needed flag rather than a hallucinated
query.
* Top results are persisted to memory in a compact form (model + pk +
score only) so backends remain serialisation-friendly.
* New ConversationalSearchAPIView mounted at
POST /api/search/conversation/ (and DELETE for clearing history).
Returns 404 when CONVERSATIONAL.ENABLED is False so the URL is safe
to leave registered globally.
* 16 new tests cover memory backends, individual nodes, end-to-end
graph behaviour and the HTTP view.
Backwards compatibility:
* All previous tests still pass unchanged (36 passed total).
* Existing /api/search/ and /api/search/similar/ endpoints are
untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sprint 3 of the LangGraph roadmap: an optional conversational search layer on top of the existing
Searcher. Stacked on top of #2 (Sprint 1+2).The new endpoint is search-first, not chat-first — it remembers a tiny per-session history, rewrites short follow-ups using the previous turn, and returns a structured
clarification_neededflag for ambiguous input rather than hallucinating a query.What's new
Settings:
CONVERSATIONALsectionMemory backends (
memory/subpackage)BaseMemoryBackend+ConversationEventdataclass.InMemoryBackend— thread-safe bounded deque, default for tests/dev.DjangoCacheBackend— works with any Django cache (incl. Redis via django-redis) without a hard Redis dependency.build_memory_backendfactory with short aliases (inmemory,cache,redis).Top results are stored in compact form (
model + pk + scoreonly), so backends stay serialisation-friendly.Conversation graph (
langgraph_conversation.py)interpret_followupresolvesmore/similar/only Xpatterns deterministically — never invents filters.maybe_clarifyreturnsclarification_needed=Truefor ambiguous short input without history.langgraphpackage.New endpoint
Returns 404 when
CONVERSATIONAL.ENABLED = Falseso the URL is safe to leave registered globally.Sample request/response:
Tests
tests/test_conversational_search.py— 16 new tests covering:Backwards compatibility
/api/search/and/api/search/similar/endpoints untouched.What's next (Sprint 4 — separate PR)
Smart structured indexing pipeline, optional streaming/event hook system, and production hardening (limits, structured logging, traces).