Repository navigation
Conversation
graph() caches the built graph per context so repeated runs skip re-evaluating every node's flag. The build also created the graph's track data, run id included, so every run for the same context reported the same runId on its $ld:ai:graph:* events. Each run now copies the cached track data with a fresh runId and passes it to route and stream_route through their opts, so the node, handoff and graph-level events of one run share one id and the next run gets another. The flag evaluations stay cached.
Contributor
Author
|
bugbot run |
apucacao
added this pull request to stack #151
October 9, 2026 15:58
Contributor
Author
|
bugbot run |
Contributor
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 30f7d4a. Configure here.
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.
Summary
Running the same
graph()twice for the same context reported both runs under one run id, so separate runs looked like one in the$ld:ai:graph:*events.graph()caches the built graph per context so it doesn't re-evaluate every node's flag on each call. The run id was created in that build, so it was cached too. Each run now gets a fresh id. Every graph event within a run still shares it, and the flag evaluations stay cached.Builds on #121. In JS the same fix is part of launchdarkly/js-ai-sdk#101.
Testing
test_graph_stream.py, for bothinvokeandstream: two runs on onegraph()instance and context get different ids, and all graph events in a run (node, handoff, success) share one. It fails on main.Note
Overview
Fixes duplicate
runIdwhen reusing a cachedgraph()build for the same context. Previously the id was created in_build_graphand cached with the topology, so twoinvoke/streamcalls looked like one run in$ld:ai:graph:*events.Each run now mints a fresh
runIdat execution time (invoke/stream) while keeping the rest of the cached track metadata. That per-run payload is passed intoroute/stream_routeas_run_track_data, and handoff success/failure events read from opts so they use the current run’s id instead of the build’s. Graph-level events (node, duration, invocation) already use the per-rungraph_track_data.Adds
TestGraphRunIdfor invoke and stream: two runs on onegraph()instance share one id within a run and differ across runs.Reviewed by Cursor Bugbot for commit 30f7d4a. Bugbot is set up for automated code reviews on this repo. Configure here.