This guide shows how to integrate LangGraph agent workflows with LaunchDarkly AgentControl. Using AgentControl configs with LangGraph lets you manage agent instructions, model configuration, and parameters outside of your application code.
This guide uses agent mode for LangGraph workflows. Agent mode uses a single instructions string rather than a messages array, which maps directly to LangGraph’s agent prompts. To learn more, read Agents.
If you’re new to AgentControl, start with the Quickstart and return to this guide when you are ready for a LangGraph-specific example.
To learn more about AgentControl-specific SDKs, read AI SDKs. For Python-specific details, read the Python AI SDK reference.
To complete this guide, you must have the following prerequisites:
Before you begin, review these key concepts.
LangGraph provides a framework for building agent workflows as directed graphs. The create_agent function (in langchain.agents; replaces the deprecated langgraph.prebuilt.create_react_agent in LangGraph 1.0+) creates a ReAct-style agent that can use tools and maintain state across conversation turns. Agents receive a system prompt that defines their behavior and capabilities.
Agent mode AgentControl configs use an instructions field instead of a messages array. This single instruction string serves as the system prompt for your agent. Agent mode is ideal for:
The agent_config function retrieves the AgentControl config variation for a given context. It returns an AIAgentConfig object that includes the customized instructions, model configuration, and a create_tracker() (Python) or createTracker() (Node.js) factory method that returns a tracker for recording metrics. Call agent_config each time you create an agent so LaunchDarkly can evaluate targeting and return the current configuration.
Install the LaunchDarkly SDKs and LangGraph packages.
Install the LangChain provider package for your model. Common provider packages include:
langchain-openai for OpenAI modelslangchain-anthropic for Anthropic modelslangchain-google-genai for Google Gemini modelsCreate an AgentControl config in agent mode to store your agent configuration.
To create an AgentControl config:
Then, create a variation:
gpt-4o OpenAI model.temperature to 0.7 and max_tokens to 2000.
Configure targeting rules to control which users receive the AgentControl config variation.
To set up the default rule:

The AgentControl config is enabled by default. After you add the integration code to your application, LaunchDarkly serves the configured variation to your users.
The integration involves these key steps:
agent_config() (Python) or aiClient.agentConfig() (Node.js).MemorySaver checkpointer.Define the agent’s tools.
Initialize the LaunchDarkly SDK and AI client, fetch the agent config, build the LangChain model with create_langchain_model (Python) or createLangChainModel (Node.js), and create the ReAct agent.
The provider reads the model name, provider, and all parameters (temperature, max tokens, and others) from the variation, maps LaunchDarkly provider names to LangChain equivalents — for example, "gemini" to "google_genai" — and returns a configured chat model. The same AgentControl config key can serve OpenAI, Anthropic, or any other provider-backed variation from the same code path.
Invoke the agent and track metrics. Each turn is one execution as far as the tracker is concerned: track_metrics_of_async (Python) / trackMetricsOf (Node.js) records duration and tracks success or error itself, so the surrounding try/except only needs to log. The Python example uses the SDK’s sum_token_usage_from_messages helper to aggregate token counts and get_tool_calls_from_response to feed track_tool_call. The Node.js example uses LangChainProvider.getAIMetricsFromResponse per message and reads msg.tool_calls directly until the matching JS helper ships.
The fallback argument to agent_config / agentConfig is optional. When omitted, LaunchDarkly returns a disabled config if the flag is off or the SDK is unreachable. Pass an explicit fallback to keep the agent running during outages.
Here is a complete working example that combines all the steps.
View metrics for your AgentControl config in the LaunchDarkly UI.
To monitor results:
LaunchDarkly displays metrics including:
Use these metrics to compare agent performance, identify cost differences, and make data-driven decisions about which configuration to use for different user segments. To learn more, read Monitor AgentControl configs.
To view aggregated metrics across all your AgentControl configs, navigate to Insights in the left navigation under the AI section. The Insights overview page displays cost, latency, error rate, invocation counts, and model distribution across your organization. To learn more, read about AI insights.

In this guide, you learned how to integrate LangGraph agent workflows with LaunchDarkly AgentControl to manage agent configuration outside of your application code.
You can now:
To explore additional capabilities, read:
For more AgentControl examples, read the other AgentControl guides in this section.