feat: Migrate LangGraph runner to AgentGraphRunnerResult; clean up legacy shape detection#156
Merged
jsonbailey merged 4 commits intomainfrom May 4, 2026
Merged
Conversation
9733a28 to
44501e3
Compare
0539ba1 to
404670d
Compare
44501e3 to
142e041
Compare
404670d to
f132154
Compare
142e041 to
fb3c0f6
Compare
f132154 to
eb1004c
Compare
fb3c0f6 to
b3547b0
Compare
eb1004c to
8a049e2
Compare
b3547b0 to
1d4ddb2
Compare
8a049e2 to
cea3780
Compare
1d4ddb2 to
6201d09
Compare
cea3780 to
f27f9b8
Compare
6201d09 to
ef4216c
Compare
f27f9b8 to
d892533
Compare
ef4216c to
8ecce16
Compare
d892533 to
13ee088
Compare
8ecce16 to
09af502
Compare
13ee088 to
3159524
Compare
09af502 to
43bc879
Compare
3159524 to
2c5671d
Compare
43bc879 to
f6df746
Compare
2c5671d to
9318539
Compare
keelerm84
approved these changes
May 4, 2026
…cy shape detection Updates LangGraphAgentGraphRunner to return AgentGraphRunnerResult with GraphMetrics (success, path, duration_ms, usage, node_metrics) instead of the legacy AgentGraphResult. Adds collect_node_metrics() to LDMetricsCallbackHandler for pure data extraction. Removes the transitional AgentGraphResult detection branch from ManagedAgentGraph now that both the OpenAI and LangGraph runners return AgentGraphRunnerResult. All graph-level and per-node tracking events are driven exclusively by the managed layer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the flush() async method and update all tests to use collect_node_metrics() which is the correct data-extraction API. The managed layer (ManagedAgentGraph) owns actual tracking; flush() was retained only for tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4411d93 to
ba4b5dd
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ba4b5dd. 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
LangGraphAgentGraphRunner.run()to returnAgentGraphRunnerResult(withGraphMetrics) instead of the legacyAgentGraphResultshapecollect_node_metrics()toLDMetricsCallbackHandlerfor pure data extraction (no LD tracker calls from the runner)isinstance(raw_result, AgentGraphRunnerResult)detection branch fromManagedAgentGraph— now that both OpenAI and LangGraph runners return the new shape, the bridge is dead codeManagedAgentGraph._flush_graph_tracking()test_langgraph_agent_graph_runner.pyto verify runner returnsAgentGraphRunnerResultand does NOT call graph tracker directlytest_tracking_langgraph.pyto verify events via handlerflush()or result shape; removes direct runner → graph tracker assertionsStack position
This is PR 11-langchain, stacked on:
After this PR, the legacy
AgentGraphResultshape is fully retired from production code.Test plan
make testpasses inpackages/ai-providers/server-ai-langchain(81 tests)uv run pytest packages/sdk/server-ai/tests/passes (149 tests)make testpasses inpackages/ai-providers/server-ai-openai(40 tests)🤖 Generated with Claude Code
Note
Medium Risk
Medium risk because it changes the LangGraph runner’s public result shape and shifts when/where tracking metrics are produced, which could break callers or alter emitted metrics if assumptions differ.
Overview
Updates
LangGraphAgentGraphRunner.run()to return the newAgentGraphRunnerResultwithGraphMetrics(content, duration, path, aggregated usage, and per-node metrics) instead of the legacyAgentGraphResult/direct tracker calls.Refactors
LDMetricsCallbackHandlerto build per-nodeLDAIMetricsincrementally and expose them vianode_metrics, removing the oldflush()path that emitted LaunchDarkly events.Tests are updated to assert the new result shape and that graph-level tracking is driven via
ManagedAgentGraph(runner no longer calls graph trackers directly), with callback-handler tests now validating pure metric accumulation.Reviewed by Cursor Bugbot for commit 95442cd. Bugbot is set up for automated code reviews on this repo. Configure here.