feat(langgraph): optional LangGraph search pipeline (Sprint 1+2)#2
Merged
Conversation
…ion and reranking Adds an opt-in orchestration layer (Sprint 1+2 combined) on top of the existing components without changing the public API. Highlights: * New LANGGRAPH settings section with safe defaults (disabled). * New langgraph_agent module with TypedDict state and 5 nodes: analyze_query, expand_query, vector_search, rerank, postprocess. * In-tree fallback runner so the package works without the langgraph package installed; uses langgraph.StateGraph when available. * New llm/ subpackage with BaseLLMBackend contract, DummyLLMBackend (deterministic, dependency-free) and a factory. * Multi-query merge with per-doc score consolidation and dedup. * Searcher.search and find_similar are unchanged in signature; when the graph fails the searcher falls back to the legacy linear path (FALLBACK_ON_ERROR=True by default). * 13 new tests (settings validation, individual nodes, end-to-end searcher behaviour with and without LangGraph). * README section documenting how to enable and configure the pipeline. Backwards compatibility: * All 8 pre-existing tests still pass unchanged. * When LANGGRAPH.ENABLED is False (default), Searcher.search executes the original linear path byte-for-byte.
This was referenced May 8, 2026
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
Combines Sprint 1 (LangGraph foundation + feature flag) and Sprint 2 (query expansion + reranking + LLM abstraction) from the planned roadmap into a single, reviewable change.
The new orchestration layer is fully opt-in — defaults keep the legacy linear path so existing deployments are byte-for-byte unchanged.
What's new
LANGGRAPHsettings sectionNew modules
langgraph_agent.py— TypedDictSearchState, 5 nodes (analyze_query,expand_query,vector_search,rerank_results,postprocess_results) and abuild_search_graphfactory.llm/subpackage —BaseLLMBackendcontract,DummyLLMBackend(deterministic, dependency-free) and a factory. Bring your own backend via dotted path.Pipeline
LangGraph dependency is optional
If
langgraphis not installed, an in-tree sequential runner with the same node structure is used. Behaviour and tests are identical either way. The newlanggraphextra installs it.Backwards compatibility
Searcher.search/Searcher.find_similarsignatures unchanged.LANGGRAPH.ENABLED = False(default), the linear path is executed verbatim.FALLBACK_ON_ERROR=True(default) means even with the graph enabled, any internal failure transparently falls back.Tests
tests/test_langgraph_search.py— 13 new tests covering:Review notes
install_requires.pytest-djangoadded to thetestextra (already used implicitly).What this PR intentionally does not do