Summary
LangGraph/LangChain have evolved significantly and the current codebase relies on deprecated APIs and imports. The app currently only runs against pinned legacy versions. We need a structured migration to the latest LangGraph/LangChain stack, update imports/usages, and keep behavior stable.
Current Problems (Concrete Symptoms)
- Deprecated agent factory:
create_react_agent is deprecated and moved to langchain.agents.create_agent.
- Deprecated tracer import:
langchain.callbacks.tracers.LangChainTracer has moved to langchain_core.tracers.langchain.LangChainTracer.
- Removed chains modules:
langchain.chains.* no longer exists in newer LangChain; graphrag_reasoning.py imports langchain.chains.combine_documents and langchain.chains.retrieval which now break with ModuleNotFoundError.
- Text splitter moved:
langchain.text_splitter.RecursiveCharacterTextSplitter moved to langchain_text_splitters.
- LangGraph API drift:
create_react_agent, ToolNode usage, and state handling differ across versions. The code currently assumes the old prebuilt API.
Impact
- Code only runs with pinned legacy versions of LangChain/LangGraph.
- Upgrading to secure versions breaks runtime imports.
- Pip-audit fails unless we keep legacy versions or ignore CVEs.
Goals
- Migrate to latest supported LangGraph + LangChain versions.
- Remove all deprecated imports and APIs.
- Keep business logic intact.
- Ensure tests and CI remain green.
- Allow dependency upgrades without pinning legacy versions.
Migration Scope (Known Hotspots)
- Agents:
talk2biomodels/agents/t2b_agent.py
talk2knowledgegraphs/agents/t2kg_agent.py
talk2scholars/agents/*
talk2cells/agents/scp_agent.py
- Tools:
talk2knowledgegraphs/tools/graphrag_reasoning.py (chains & splitters)
- Streamlit apps:
app/frontend/utils/streamlit_utils.py
app/frontend/streamlit_app_talk2cells.py
Suggested Plan
- Upgrade dependencies (LangChain/LangGraph stack + related) and regenerate lock.
- Replace deprecated APIs/imports:
create_react_agent → langchain.agents.create_agent
langchain.callbacks.tracers.LangChainTracer →
langchain_core.tracers.langchain.LangChainTracer
langchain.chains.* → new retrieval/LLM flow
langchain.text_splitter → langchain_text_splitters
- Refactor ToolNode usage where required by the new API.
- Run full test suite, fix breakages.
- Update CI pipelines and remove legacy pinning.
Acceptance Criteria
- App runs on latest LangChain/LangGraph without deprecation warnings or import errors.
- Pip-audit passes without ignoring LangChain CVEs.
- Tests and CI pass at 100% coverage where required.
Notes
This migration should be done in stages to avoid breaking production, and each step should be verified against tests and Streamlit runtime.
Summary
LangGraph/LangChain have evolved significantly and the current codebase relies on deprecated APIs and imports. The app currently only runs against pinned legacy versions. We need a structured migration to the latest LangGraph/LangChain stack, update imports/usages, and keep behavior stable.
Current Problems (Concrete Symptoms)
create_react_agentis deprecated and moved tolangchain.agents.create_agent.langchain.callbacks.tracers.LangChainTracerhas moved tolangchain_core.tracers.langchain.LangChainTracer.langchain.chains.*no longer exists in newer LangChain;graphrag_reasoning.pyimportslangchain.chains.combine_documentsandlangchain.chains.retrievalwhich now break withModuleNotFoundError.langchain.text_splitter.RecursiveCharacterTextSplittermoved tolangchain_text_splitters.create_react_agent, ToolNode usage, and state handling differ across versions. The code currently assumes the old prebuilt API.Impact
Goals
Migration Scope (Known Hotspots)
talk2biomodels/agents/t2b_agent.pytalk2knowledgegraphs/agents/t2kg_agent.pytalk2scholars/agents/*talk2cells/agents/scp_agent.pytalk2knowledgegraphs/tools/graphrag_reasoning.py(chains & splitters)app/frontend/utils/streamlit_utils.pyapp/frontend/streamlit_app_talk2cells.pySuggested Plan
create_react_agent→langchain.agents.create_agentlangchain.callbacks.tracers.LangChainTracer→langchain_core.tracers.langchain.LangChainTracerlangchain.chains.*→ new retrieval/LLM flowlangchain.text_splitter→langchain_text_splittersAcceptance Criteria
Notes
This migration should be done in stages to avoid breaking production, and each step should be verified against tests and Streamlit runtime.