feat: add topological flow reasoning for mechanistic queries - #144
bhavyakeerthi3 wants to merge 7 commits into
Conversation
…y data between nodes Without this field, LangGraph silently drops the topology data returned by identify_flow() before verify_mechanism() can read it, making the entire topological flow reasoning feature a no-op in production. Also adds a regression test (test_flow_context_in_state) to ensure the field is never accidentally removed.
9bef654 to
e0457c0
Compare
|
Closing as superseded by #153, which is your own later version of this work — same feature, same core files ( Since the review will happen there, one finding that applies to both and is worth flagging now rather than at merge time:
It is also no longer necessary. from langchain_classic.chains.query_constructor.schema import AttributeInfoWhen this PR was opened that import path was genuinely in flux, so the shim was a reasonable response at the time. It just is not the problem any more. Worth knowing before rebasing #153: Thank you for the work — it is going forward on #153. |
Summary
Implements Topological Flow Reasoning to handle mechanistic biological queries (e.g. "What happens after protein phosphorylation?") that standard RAG cannot answer correctly.
Fixes #143
Motivation
RAG retrieval returns keyword-matched snippets with no awareness of reaction ordering. Biological pathways have strict causal sequences — a hallucinated causal chain is worse than no answer because it sounds authoritative. This PR makes the agent verify causal claims against the Reactome Graph before responding.
Key Changes
src/tools/reactome_topology.pysrc/agent/tasks/flow_reasoner.pysrc/agent/profiles/cross_database.pyidentify_flowandverify_mechanismnodes to agent graphtests/test_flow_reasoning.pyHow It Works
Resilience
Added import fallbacks for
AttributeInfoto handle varied LangChain environments without breaking existing functionality.Test Results
Relation to Other PRs
flow_contextgathered here provides the exact evidence needed for faithfulness grading on mechanistic sequences