Skip to content

feat: Graph tracking refactor — ManagedAgentGraph drives tracking for new runner shape#154

Draft
jsonbailey wants to merge 1 commit intojb/aic-2388/enrich-metricsfrom
jb/aic-2174/graph-tracking-refactor
Draft

feat: Graph tracking refactor — ManagedAgentGraph drives tracking for new runner shape#154
jsonbailey wants to merge 1 commit intojb/aic-2388/enrich-metricsfrom
jb/aic-2174/graph-tracking-refactor

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

Summary

Moves graph-level LaunchDarkly tracking from inside the runner implementations to the ManagedAgentGraph managed layer.

  • ManagedAgentGraph.run() now detects runner result type via isinstance:
    • AgentGraphRunnerResult (new shape): managed layer drives all graph-level tracking (path, duration, success/failure, total tokens) from result.metrics via the graph tracker
    • AgentGraphResult (legacy shape): tracking already occurred inside the runner; managed layer wraps the result without additional tracking
  • ManagedAgentGraph now accepts an optional graph: AgentGraphDefinition parameter used to create the graph tracker
  • LDAIClient.create_agent_graph() passes the resolved graph definition as graph=graph

Deliberate bridge pattern: The legacy detection branch exists because PR 11-openai and PR 11-langchain have not yet migrated their runners to return AgentGraphRunnerResult. Once both runners are migrated, the legacy AgentGraphResult branch becomes dead code and will be removed in PR 11-langchain's cleanup commit.

Depends on

Test plan

  • All existing tests pass (uv run pytest packages/sdk/server-ai/tests/)
  • New tests: test_managed_agent_graph_run_handles_new_shape, test_managed_agent_graph_new_shape_drives_tracking, test_managed_agent_graph_new_shape_no_graph_skips_tracking
  • Legacy tests continue to pass (AgentGraphResult path unchanged)

🤖 Generated with Claude Code

@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from cbe2eda to 4f12618 Compare April 29, 2026 13:15
@jsonbailey jsonbailey force-pushed the jb/aic-2174/graph-tracking-refactor branch from fcbcb18 to 9286d53 Compare April 29, 2026 13:15
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from 4f12618 to 351f249 Compare April 29, 2026 13:19
@jsonbailey jsonbailey force-pushed the jb/aic-2174/graph-tracking-refactor branch from 9286d53 to 72fc13e Compare April 29, 2026 13:19
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from 351f249 to ef03235 Compare April 29, 2026 13:22
@jsonbailey jsonbailey force-pushed the jb/aic-2174/graph-tracking-refactor branch from 72fc13e to bde4f09 Compare April 29, 2026 13:22
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from ef03235 to e5ecc6a Compare April 29, 2026 13:52
@jsonbailey jsonbailey force-pushed the jb/aic-2174/graph-tracking-refactor branch from bde4f09 to c376011 Compare April 29, 2026 13:52
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from e5ecc6a to 1636446 Compare April 29, 2026 13:57
@jsonbailey jsonbailey force-pushed the jb/aic-2174/graph-tracking-refactor branch from c376011 to 7f67e4f Compare April 29, 2026 13:57
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from 1636446 to 0fae2df Compare April 29, 2026 14:38
@jsonbailey jsonbailey force-pushed the jb/aic-2174/graph-tracking-refactor branch from 7f67e4f to a89c6a2 Compare April 29, 2026 14:38
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from 0fae2df to a468a7f Compare April 29, 2026 16:33
… new runner shape

ManagedAgentGraph.run() now detects the runner result type and dispatches
accordingly:
- AgentGraphRunnerResult (new shape): managed layer drives all graph-level
  tracking from result.metrics (path, duration, success/failure, total tokens)
  via the graph tracker. Node-level tracking from node_metrics will be wired
  once runners populate that field (PR 11-openai/langchain).
- AgentGraphResult (legacy shape): tracking already occurred inside the runner;
  managed layer wraps result without additional tracking.

ManagedAgentGraph now accepts an optional graph parameter (AgentGraphDefinition)
used to create the graph tracker. LDAIClient.create_agent_graph() passes the
resolved graph definition. This is a deliberate bridge pattern: the legacy
detection branch will be removed once both runners are migrated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey force-pushed the jb/aic-2174/graph-tracking-refactor branch from a89c6a2 to c69a9ff Compare April 29, 2026 16:33
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