feat(langchain): add LangChain and LangGraph context adapters#1964
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
qin-ctx
left a comment
There was a problem hiding this comment.
Thanks for putting together the LangChain/LangGraph integration. I found two blocking issues that should be addressed before merge: the middleware currently falls back to a shared default session when no thread/session id is present, and the LangGraph store cannot resolve canonicalized user/agent store URIs under namespace isolation.
qin-ctx
left a comment
There was a problem hiding this comment.
Thanks for the LangChain/LangGraph integration work. I re-reviewed the latest head and found two blocking issues plus one test-gating suggestion. The previous blocking comments about the shared LangGraph fallback session and canonical store URI parsing look fixed in this head.
qin-ctx
left a comment
There was a problem hiding this comment.
Thanks for the updates. I re-reviewed the current head and the prior two blocking comments look addressed. I found two remaining blocking issues: the HTTP user_id connection parameter is currently ignored by the underlying client path, and LangGraph store filter range comparisons can raise on missing or incompatible fields instead of skipping non-matches.
Description
This adds optional LangChain and LangGraph adapters so Python agent applications can use OpenViking as their context backend without each app writing its own glue code.
The usual deployment is: the LangChain or LangGraph app keeps owning the agent flow and LLM calls, while OpenViking handles context storage, indexing, retrieval, session memory, and source information returned with retrieved context.
Changes
openviking.integrations.langchainwith lazy exports for:with_openviking_context()for LangChain runnable context injection and session captureOpenVikingContextMiddlewarefor LangGraph agent context injection and post-run captureOpenVikingChatMessageHistoryfor LangChain message history backed by OpenViking sessionsOpenVikingRetrieverfor LangChain document retrieval from OpenViking search/find resultsOpenVikingStorefor LangGraph durable store usagecreate_openviking_tools()for exposing common OpenViking read/search/write tools to agentslangchainandlanggraphpackage extras.examples/langchain-langgraph/for LangChain RAG, LangChain context backend, LangChain message history, LangGraph agent tools/store, and LangGraph middleware.Design Notes
The adapters follow the host framework shapes instead of introducing a separate agent framework. LangChain users get runnables, retrievers, chat history, and tools. LangGraph users get middleware and a
BaseStore-style store. OpenViking remains the source of truth for sessions, URIs, indexing, retrieval, and persistence.LangChain/LangGraph dependencies are optional and loaded lazily, so installing or importing core OpenViking does not pull those frameworks in unless the user opts into the integration extras.
Validation
uv run --extra test --extra langchain --extra langgraph pytest tests/client/test_http_client_config.py tests/unit/test_langchain_integration.py tests/integration/langchain_langgraph/test_smoke.py -q60 passeduv run --extra test --extra langchain --extra langgraph pytest tests/integration/langchain_langgraph/live_e2e.py -q -s5 passedagainst a fresh local OpenViking workspaceuv run --extra dev ruff format --check ...uv run --extra dev ruff check ...git diff --checkThe tests exercise real LangChain and LangGraph application flows, not just mocked adapter calls.