Skip to content

feat: Add ManagedAgentGraph support (PR-6)#111

Open
jsonbailey wants to merge 2 commits intojb/aic-1664/graph-tracking-improvementsfrom
jb/aic-1664/managed-agent-graph
Open

feat: Add ManagedAgentGraph support (PR-6)#111
jsonbailey wants to merge 2 commits intojb/aic-1664/graph-tracking-improvementsfrom
jb/aic-1664/managed-agent-graph

Conversation

@jsonbailey
Copy link
Contributor

@jsonbailey jsonbailey commented Mar 25, 2026

feat: Add OpenAIAgentGraphRunner support
feat: Add LangGraphAgentGraphRunner support


Note

Medium Risk
Adds a new agent-graph execution surface across the SDK and introduces new provider runners while also changing LDAIConfigTracker.track_metrics_of from async to sync (adding track_metrics_of_async), which can break integrations and subtly affect tracking behavior.

Overview
Adds managed agent graph execution via new ManagedAgentGraph and LDAIClient.create_agent_graph(), which resolves an AgentGraphDefinition, creates a provider-specific runner, and exposes run().

Introduces provider implementations for graph execution: OpenAIAgentGraphRunner (OpenAI Agents SDK) and LangGraphAgentGraphRunner (LangGraph), plus create_agent_graph() factory hooks and exports for both providers; runners record graph path/latency/success, node-level metrics, and tool calls.

Updates tracking APIs to support graphs by adding optional graph_key metadata to config-level events, adding tool-call tracking on LDAIConfigTracker, making AIGraphTracker.track_total_tokens tolerate missing usage, and splitting metric tracking into sync track_metrics_of() and async track_metrics_of_async(); docs/tests are updated accordingly.

Written by Cursor Bugbot for commit e57a147. This will update automatically on new commits. Configure here.

@jsonbailey jsonbailey changed the title feat: Add ManagedAgentGraph support feat: Add ManagedAgentGraph support (PR-6) Mar 25, 2026
@jsonbailey jsonbailey marked this pull request as ready for review March 25, 2026 22:05
@jsonbailey jsonbailey requested a review from a team as a code owner March 25, 2026 22:05
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.


runner = await RunnerFactory.create_agent_graph(
graph, tools or {}, default_ai_provider
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awaiting synchronous RunnerFactory.create_agent_graph causes TypeError

High Severity

RunnerFactory.create_agent_graph() is a synchronous @staticmethod that returns Optional[Any] directly, not a coroutine. Using await on its return value will raise a TypeError at runtime (e.g. "object 'OpenAIAgentGraphRunner' can't be used in 'await' expression"). The tests pass only because they patch this method with AsyncMock, masking the real failure.

Fix in Cursor Fix in Web

instructions=f'[RECOMMENDED_PROMPT_PREFIX] {node_config.instructions or ""}',
handoffs=list(agent_handoffs),
tools=list(agent_tools),
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenAI Agent created without configured model name

High Severity

The Agent constructor is called without the model parameter, so every agent defaults to the OpenAI SDK's built-in default model instead of using the model configured in LaunchDarkly (e.g., node_config.model.name). The model config is validated to exist (line 119) and used for tool definitions (line 122), but its name is never forwarded to the Agent. The LangGraph sibling runner correctly passes node_config.model.name to init_chat_model.

Fix in Cursor Fix in Web

jsonbailey and others added 2 commits March 25, 2026 17:17
…aphRunner

Implements PR 5 — ManagedAgentGraph + create_agent_graph():

ldai:
- managed_agent_graph.py: ManagedAgentGraph wrapper holding AgentGraphRunner
  + AIGraphTracker; exposes run(), get_agent_graph_runner(), get_tracker()
- LDAIClient.create_agent_graph(key, context, tools): resolves graph via
  agent_graph(), delegates to RunnerFactory, returns ManagedAgentGraph
- Exports ManagedAgentGraph from top-level ldai package

ldai_openai:
- OpenAIAgentGraphRunner(AgentGraphRunner): builds agents via reverse_traverse
  using the openai-agents SDK; auto-tracks path, tool calls, handoffs,
  latency, invocation success/failure
- OpenAIRunnerFactory.create_agent_graph(graph_def, tools) -> OpenAIAgentGraphRunner

ldai_langchain:
- LangGraphAgentGraphRunner(AgentGraphRunner): builds a LangGraph StateGraph
  via traverse(); auto-tracks latency and invocation success/failure
- LangChainRunnerFactory.create_agent_graph(graph_def, tools) -> LangGraphAgentGraphRunner

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n rollup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey force-pushed the jb/aic-1664/managed-agent-graph branch from 226dfdf to e57a147 Compare March 25, 2026 22:22
@jsonbailey jsonbailey changed the base branch from jb/aic-1664/runner-abcs to jb/aic-1664/graph-tracking-improvements March 25, 2026 22:23
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