Skip to content

Conversation

@andrewklatzke
Copy link

@andrewklatzke andrewklatzke commented Jan 15, 2026

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Describe the solution you've provided

This pull requests implements the following functionality:

  • Adds preliminary support for "Agent Graph" objects within the LaunchDarkly SDK, fetched by their configuration key
ai_client.agent_graph(config_key, context_value) -> AgentGraphDefinition
  • Adds the AgentGraphDefinition class which allows traversal of a graph through traverse and reverse_traverse methods:
    def handle_traversal(node: AIAgentConfig, ctx: Dict[str, Agent]):
        node_config = node.get_config() # Returns an AIAgentConfig
        node_edges = node.get_edges() # Returns Edge[]
        
        handoffs = [ctx[edge.target_config] for edge in node_edges] # Specific to OpenAI implementation
        
        return Agent(
            name=node_config.key,
            instructions=node_config.instructions,
            handoffs=handoffs,
            tools=[],
        )

    root = graph.reverse_traverse(fn=handle_traversal)

Describe alternatives you've considered

This is the implementation of a new feature within LaunchDarkly. There weren't alternatives considered as this is the initial implementation and offering regarding this feature.

Additional context

This PR will be followed up with other PRs introducing:

  • A layer for instrumenting framework-specific implementations of this graph method that will provide easier entry-points for specific frameworks
  • Framework-specific implementations

Note

Adds a retrievable AI agent graph with traversal utilities.

  • New AgentGraphDefinition with traverse and reverse_traverse, node/edge accessors, and terminal/root helpers
  • New models: Edge, AIAgentGraphConfig; AgentGraphNode internal representation
  • LDAIClient.agent_graph(key, context) fetches graph variations, validates enabled agents, builds nodes, and returns an enabled/disabled graph definition
  • Public exports updated in ldai/__init__.py
  • Tests: graph retrieval/validation (disabled/no root), node building, parent/child queries, traversal order, and handoff propagation

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

@andrewklatzke andrewklatzke requested a review from a team as a code owner January 15, 2026 01:11
@andrewklatzke andrewklatzke changed the title [REL-11697] agent_graph sdk method feat: agent_graph SDK method Jan 15, 2026
# AI Config Agent Graph
# ============================================================================
@dataclass
class AIAgentGraphConfig:
Copy link
Contributor

Choose a reason for hiding this comment

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

For all other configs, the enabled value is part of the config and not wrapped. It's worth a debate if the reason to separate this into the Response is so you don't have to make all the fields optional incase it is disabled. If we make that change we should consider it for all other configs and potentially make the AIAgentGraphResponse a generic.

Copy link
Author

Choose a reason for hiding this comment

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

I can add in a synthetic enabled directly onto the config object if we'd prefer to keep it the same as the others

Copy link
Author

Choose a reason for hiding this comment

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

I'm actually updating to this - it makes things much cleaner type-wise. I added an enabled member to the config object and the agent_graph object inherits from that. This will also give us an avenue to handle provider-specific errors (ie you're using langgraph but we can't find your creds) and disable the graph if necessary

@andrewklatzke
Copy link
Author

Updated to include enabled on both the config and the agent_graph object so it matches previous patterns.

Would now be used as:

    agent_graph = ai_client.agent_graph("test-agent-graph", context)

    if agent_graph.enabled:
        await run_open_ai_agents(agent_graph)
    else:
        print("Agent graph is not enabled")

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.

3 participants