Add reactome_preceding_events: what has to happen before an event - #35
Merged
Merged
Conversation
Harvested from reactome/reactome_chatbot#153 by @bhavyakeerthi3. That PR added a second Content Service client inside the chatbot -- plain `requests`, no tests -- to answer mechanistic questions about sequence. The client belongs here, where the Content Service is already wrapped with verified shapes and a live sweep. The idea was the valuable part, and it was a real gap: containment was covered (`reactome_pathway_contained_events`, "what is this pathway made of") and ordering was not ("what leads up to this"). Reactome models ordering on the *later* event: an event lists what precedes it. The forward direction is not symmetrically available -- `followingEvent` is absent at the top level and appears nested as bare dbIds with no stable IDs -- so this walks backwards, which is the direction the data supports. Saying so in the tool description matters more than it looks: a model asked "what happens after X" should know it is getting the answer to a different question. Multi-hop, which is the point. One step back is already in the raw object; the cascade is not: ## What happens before R-HSA-69205 ### 1 step back - Cyclin D:CDK4/6 phosphorylates RB1 ... (R-HSA-69227) [Reaction] ### 2 steps back - CDK4/6:CCND complexes are activated by T-loop phosphorylation (R-HSA-8942836) - RB1 translocates to the nucleus (R-HSA-9659820) [BlackBoxEvent] ### 3 steps back - Translocation of CDK4/6:CCND complexes ... (R-HSA-8942803) An event with nothing before it says so plainly. Most events are entry points, and an empty list would read as a failed lookup rather than an answer. Two guards worth their tests: already-seen events are not revisited, because Reactome ordering can loop back and the depth budget would otherwise be spent re-fetching; and entries without a stable ID are skipped, since a reader cannot follow one up. 58 -> 59 tools, 101 -> 107 tests, sweep covers all 59 with 22 content expectations and is clean. The expectation for this tool asserts it found real ordering, not just that it answered -- a tool that only ever said "nothing precedes this" would otherwise look healthy. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Harvested from reactome_chatbot#153 by @bhavyakeerthi3.
That PR added a second Content Service client inside the chatbot — plain
requests, no tests — to answer mechanistic questions about sequence. The client belongs here, where the Content Service is already wrapped with verified shapes and a live sweep. The idea was the valuable part, and it was a real gap: containment was covered (reactome_pathway_contained_events— "what is this pathway made of") and ordering was not ("what leads up to this").Backwards, because that is the direction the data supports
Reactome models ordering on the later event: an event lists what precedes it. The forward direction is not symmetrically available —
followingEventis absent at the top level and appears nested as bare dbIds with no stable IDs.The tool description says so, which matters more than it looks: a model asked "what happens after X" should know it's getting the answer to a different question.
Multi-hop, which is the point
One step back is already in the raw object. The cascade is not:
An event with nothing before it says so plainly. Most events are entry points, and an empty list would read as a failed lookup rather than an answer.
Two guards, each with a test
Verification
npm run checkgreenGET /data/query/R-HSA-69205🤖 Generated with Claude Code