Skip to content

feat: add topological flow reasoning for mechanistic queries#144

Open
bhavyakeerthi3 wants to merge 7 commits intoreactome:mainfrom
bhavyakeerthi3:feat/topological-flow-reasoning
Open

feat: add topological flow reasoning for mechanistic queries#144
bhavyakeerthi3 wants to merge 7 commits intoreactome:mainfrom
bhavyakeerthi3:feat/topological-flow-reasoning

Conversation

@bhavyakeerthi3
Copy link
Copy Markdown

@bhavyakeerthi3 bhavyakeerthi3 commented Mar 13, 2026

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

File Change
src/tools/reactome_topology.py New tool — fetches reaction participants and preceding/subsequent events from Reactome Content Service API
src/agent/tasks/flow_reasoner.py New task node — curator-level prompt that treats graph data as ground truth
src/agent/profiles/cross_database.py Added identify_flow and verify_mechanism nodes to agent graph
tests/test_flow_reasoning.py Integration tests for all three new nodes

How It Works

User query ("what happens after X?")
        ↓
CrossDatabaseGraphBuilder detects flow keywords
        ↓
identify_flow → extracts Stable IDs, fetches topology context
        ↓
verify_mechanism → grounds causal chain against Reactome Graph
        ↓
Verified answer returned

Resilience

Added import fallbacks for AttributeInfo to handle varied LangChain environments without breaking existing functionality.

Test Results

tests/test_flow_reasoning.py::test_identify_flow        PASSED
tests/test_flow_reasoning.py::test_verify_mechanism     PASSED
tests/test_flow_reasoning.py::test_decide_next_steps    PASSED

Relation to Other PRs

…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.
@bhavyakeerthi3 bhavyakeerthi3 force-pushed the feat/topological-flow-reasoning branch from 9bef654 to e0457c0 Compare March 14, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support causal chain queries for mechanistic biological reasoning

1 participant