feat: implement multi-hop pathway traversal for deeper mechanistic reasoning - #153
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.
|
Staying open as the live version of this work — #144 is closed as superseded by it. Being straight about where it stands: this needs reworking rather than rebasing, for two separate reasons.
It is also solved already. from langchain_classic.chains.query_constructor.schema import AttributeInfoWhen this PR was opened those import paths really were moving, so the shim was a fair response to the situation at the time. It just is not the situation any more. On the feature itself, which is the part worth keeping: multi-hop traversal changes what reaches the LLM, so it needs a before-and-after on the golden questions like every other retrieval change here — see the note on #116 and #133. The evaluator that produces that measurement is being fixed in #211. It also overlaps in intent with Thank you for this, and sorry for the long silence. |
|
The idea in here was right and is now shipped — as reactome-mcp#35, What was rightContainment was already covered — "what is this pathway made of" — and ordering was not. "What leads up to this" is a different question, it is genuinely mechanistic, and nothing in the system could answer it. You found a real gap. Multi-hop was also the right instinct. One step back is already sitting in the raw object; the cascade is what has value: Why it moved rather than merged
One thing I learned putting it there, which your version could not have known: One thing to carry forward
Worth knowing either way: Thank you for this — it is the second of your PRs this week whose idea landed. Sorry it took six months to say so. |
Fixes #152
Description
This PR implements recursive traversal in
ReactomeTopologyTool. Previously the tool fetched only immediate local context direct inputs, outputs, and one level of preceding events. This enhancement allows the agent to follow both causal and hierarchical links recursively, providing significantly deeper mechanistic context.Changes
get_flow_contextto follow multi-step hops through the Reactome graphhasEvent(Pathway → Sub-segment) andprecedingEvent(Reaction → Upstream trigger)max_depth=2default with per-level breadth cap of 3 events — balances context richness against LLM window limitsImpact
The agent can now answer complex process-oriented queries like "What triggers this cascade?" by tracing causal flow across multiple hops in the Reactome pathway network — rather than seeing only the immediate reaction context.
Verification
R-HSA-109581) correctly expanded into sub-pathwaysR-HSA-111452Files Affected
src/tools/reactome_topology.pytests/test_flow_reasoning.py