Skip to content

Add reactome_preceding_events: what has to happen before an event - #35

Merged
adamjohnwright merged 1 commit into
mainfrom
feat/event-ordering
Sep 16, 2026
Merged

adamjohnwright merged 1 commit into
mainfrom
feat/event-ordering

Conversation

@adamjohnwright

Copy link
Copy Markdown
Contributor

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 availablefollowingEvent is 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:

## 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 from cytoplasm to nucleus (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, each with a test

  • Already-seen events are not revisited. Reactome ordering can loop back, and the depth budget would otherwise be spent re-fetching the same events.
  • Entries without a stable ID are skipped, since a reader cannot follow one up.

Verification

  • 58 → 59 tools, 101 → 107 tests, npm run check green
  • sweep covers all 59 with 22 content expectations, exit 0
  • the expectation for this tool asserts it found real ordering, not merely that it answered — a tool that only ever said "nothing precedes this" would otherwise look healthy
  • shapes verified against live Reactome; fixtures copied from GET /data/query/R-HSA-69205

🤖 Generated with Claude Code

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>
@adamjohnwright
adamjohnwright merged commit 53cff32 into main Sep 16, 2026
4 checks passed
@adamjohnwright
adamjohnwright deleted the feat/event-ordering branch September 16, 2026 14:22
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.

1 participant