Quickstart for AgentControl

Overview

AgentControl lets you manage model configuration and instructions for your AI agents outside of your application code. With AgentControl, you can update prompts and models without redeploying.

By the end of this quickstart, you will have:

  • Created your first agent-based config
  • Deployed your config and called it from your application
  • Made a change to your prompt or model without redeploying
Scope of this quickstart

This quickstart focuses on AgentControl configs in completion mode, which lets you configure prompts with messages and roles for single-step model responses. Completion mode supports multi-message prompts, including chat-style prompts. Completion mode does not map to a specific provider API, so you can use it with any provider LaunchDarkly supports.

AgentControl configs can also be created in agent mode, which uses instructions to define multi-step workflows. Agent mode is documented separately in Agents.

Follow the steps below to incorporate AgentControl configs into your app, or use the in-app onboarding to set up your first config directly in the LaunchDarkly UI.

Prerequisites

To complete this quickstart, you need the following:

  • A LaunchDarkly account and a server-side SDK key for your environment. To find your SDK key, read SDK credentials. If you haven’t installed a LaunchDarkly SDK yet, continue reading. This topic explains how to install a supported SDK.
  • A LaunchDarkly role that allows AgentControl config actions. The LaunchDarkly Project Admin, Maintainer, and Developer project roles, as well as the Admin and Owner base roles, include this permission.
  • An API key for your model provider, such as OpenAI or Anthropic, made available to your application as an environment variable.
  • Python 3.10 or higher. To get started with NodeJS or other languages, read the AI SDK documentation.

This quickstart uses LangChain as the agent framework. You can adapt the same configuration code to the OpenAI Agents SDK, Strands, or the Claude Agent SDK. For an end-to-end code sample showing different frameworks and model providers, read the example code.

Complete the in-app quickstart

This procedure documents the process of installation through the built-in onboarding experience.

Using an AI coding assistant?

You can set up AgentControl by giving a prompt to your coding assistant. In the quickstart workflow, select Install with AI, choose your LLM provider, and give it the prompt available in the UI.

You can connect your app to LaunchDarkly with an AI agent or with a manual installation process. The procedure below explains how to connect to LaunchDarkly manually.

Step 1: Install the SDK

First, install the LaunchDarkly server-side SDK and AI SDK, as well as the agent framework you want to use.

Installing manually

  1. In the in-app quickstart, click Install manually to reveal the SDK configuration instructions.
  2. Choose between using your existing app or a sample app.
  3. Click to select your SDK language. The instructions for installation update based on which language you choose. In this example, we use Python and LangChain.
Python
$pip install launchdarkly-server-sdk
$pip install launchdarkly-server-sdk-ai
$pip install langchain langchain-anthropic

To get started with other frameworks or model providers, read the AgentControl guides.

Step 2: Initialize the client

Initialize the client to connect LaunchDarkly to your app. To do this, you must have your LaunchDarkly SDK key. To find your SDK key, read SDK credentials.

Python
1import ldclient
2from ldclient.config import Config
3from ldai.client import LDAIClient
4from ldai import AIAgentConfig, AIAgentConfigDefault
5from langchain.agents import create_agent
6from langchain.messages import HumanMessage
7
8ldclient.set_config(Config("YOUR-SDK-KEY"))
9aiclient = LDAIClient(ldclient.get())
10context = ldclient.Context.create("user-123")
11
12config = aiclient.agent_config('YOUR-CONFIG-NAME', context, AIAgentConfigDefault())
13tracker = config.tracker
14
15
16def handle_agent_call_langchain(
17 config: AIAgentConfig,
18 user_input: str,
19) -> str:
20 model = config.model.get_parameter("name") if config.model else "anthropic:claude-sonnet-4-6"
21
22 agent = create_agent(
23 model=model,
24 system_prompt=config.instructions,
25 )
26
27 response = agent.invoke({"messages": [HumanMessage(user_input)]})
28 return response["messages"][-1].content

Step 3: Create an agent-based config in LaunchDarkly

Create an agent-based config to store your model settings and instructions. You can do this through the LaunchDarkly UI, or agentically using the LaunchDarkly MCP server from your AI coding assistant. For example, Claude Code and Cursor can both perform this task.

To create the config in the UI:

  1. In the left navigation, select Agents, then Agents.

  2. Click Configs, then Create config. The “Create config” dialog opens, with Completion selected by default.

    The "Create config" dialog.

    The "Create config" dialog.
  3. Enter a name for your config, and optionally assign a maintainer.

Save the config key

When you name your config, a key generates automatically. Copy and save this key now. You’ll use it in Step 5.

  1. (Optional) If you use flags and segments, you can click Add views to create a view of this config.
  2. Click Create.

After you create the config, the Variations tab appears.

Then, create a variation. Every completion-based config has one or more variations. Each variation includes a model configuration and, optionally, one or more messages.

Here’s how:

  1. In the Variations tab, replace “Untitled variation” with a variation Name. You’ll use this to refer to the variations when you set up targeting rules below.
  2. Click Select a model and choose the model to use.
  3. (Optional) Select a message role and enter the message for the variation. If you’d like to customize the message at runtime, use {{ example_variable }} or {{ ldctx.example_context_attribute }} within the message. The LaunchDarkly AI SDK will substitute the correct values when you customize the config from within your app.
    • To learn more about how variables and context attributes are inserted into messages at runtime, read Customizing configs.
  4. Click Review and save.

Here’s an example of a completed variation:

The Variations tab of a config with one variation.

The Variations tab of a config with one variation.

Here’s the variation message for this example. You can copy this if you’re working through this quickstart in your own project:

Example instructions
You are a helpful weather assistant. Use the get_weather tool to look up
current conditions for any location the user asks about, then answer
concisely in plain language.
  1. Click Review and save.

To learn more about configuring agent variations, read Agents.

Step 4: Set up targeting

When you’re ready to add more config variations, come back to this step and set up additional targeting rules. If you are familiar with LaunchDarkly’s flag targeting, the process is very similar: with AgentControl, you can target individuals or segments, or target contexts with custom rules. To learn how, read Config targeting.

  1. Select the Targeting tab for your agent-based config.
  2. In the Default rule section, click Edit.
  3. Set the default rule to serve your new variation.
  4. Click Review and save.

The Targeting tab for an agent-based config, showing the Default rule with the variation dropdown open.

Your agent-based config is now active. When your application calls the SDK, LaunchDarkly evaluates the targeting rules and returns the variation you configured.

To learn more, read Config targeting.

Step 5: Use the agent-based config with your agent framework

First, retrieve the agent-based config in your application. Replace your-agent-config-key with config Key you saved in Step 3:

Python
1from ldai import AIAgentConfigDefault
2
3config = aiclient.agent_config(
4 "your-agent-config-key",
5 context,
6 AIAgentConfigDefault(),
7)

Next, pass the model name and instructions from config into your agent framework. The example below uses LangChain:

LangChain
1from ldai import AIAgentConfig
2from langchain.agents import create_agent
3from langchain.messages import HumanMessage
4
5
6def handle_agent_call_langchain(
7 config: AIAgentConfig,
8 user_input: str,
9) -> str:
10 model = config.model.get_parameter("name") if config.model else "anthropic:claude-sonnet-4-5"
11
12 agent = create_agent(
13 model=model,
14 system_prompt=config.instructions,
15 )
16
17 response = agent.invoke({"messages": [HumanMessage(user_input)]})
18 return response["messages"][-1].content

Finally, run the agent:

Python
1response = handle_agent_call_langchain(
2 config=config,
3 user_input="Hello, what can you help me with?",
4)
5print(response)

For an equivalent setup with the OpenAI Agents SDK, Strands, or the Claude Agent SDK, read Example code.

Step 6: Make a change without redeploying

One of the key benefits of AgentControl is that you can update your model or prompt at any time without redeploying your application.

To update without redeploying:

  1. Select the Variations tab for your agent-based config.
  2. Open your variation and change the model, model provider, or instructions.
  3. Click Review and save.

LaunchDarkly immediately serves the updated configuration to your application. The next time your application calls the SDK, it receives the new model and instructions without needing to redeploy.

Step 7: Monitor the agent-based config

In the config page, click the Monitoring tab. When end users use your application, LaunchDarkly monitors config performance. Metrics update approximately every minute.

To learn more, read Monitor config performance.

Summary

Congratulations! You now have an agent-based config that can:

  • Load model and instructions from LaunchDarkly at runtime, so your app doesn’t hard-code either
  • Change in production without redeploying, by editing the variation in LaunchDarkly
  • Keep a full version history of every change to prompts and model settings
  • Report cost, token usage, and error rates on the Monitoring tab as real traffic flows through

From here, add a judge, run evals, log traces, and explore the managed AI SDKs.

Example code

This section shows an end-to-end code sample with different frameworks and model providers.

1import ldclient
2from ldclient.config import Config
3from ldai.client import LDAIClient
4from ldai import AIAgentConfig, AIAgentConfigDefault
5from agents import Agent
6from agents.run import Runner
7
8ldclient.set_config(Config("YOUR_SDK_KEY"))
9aiclient = LDAIClient(ldclient.get())
10context = ldclient.Context.create("user-123")
11
12config = aiclient.agent_config('your-agent-config-key', context, AIAgentConfigDefault())
13tracker = config.tracker
14
15
16async def handle_agent_call_openai(
17 name: str,
18 config: AIAgentConfig,
19 user_input: str,
20) -> str:
21 model = config.model.get_parameter("name") if config.model else "gpt-5"
22 root = Agent(
23 name=name,
24 instructions=config.instructions,
25 handoffs=[],
26 tools=[],
27 model=model,
28 )
29 response = await Runner.run(root, user_input)
30 return response.final_output

Evaluation results appear on the Monitoring tab as metrics such as accuracy, relevance, and toxicity.

To learn more about evaluation patterns and programmatic usage, read Online evaluations.

Next steps

Now that you have a working config and can read its evaluation results, you can continue to build complexity on that config or create another to do something else.

Here are some options:

Learn more about AgentControl

The following sections provide answers to common questions about working with AgentControl.

Integration with AI providers

In AgentControl, LaunchDarkly does not handle the integration to the AI provider. The LaunchDarkly AI SDKs provide your application with model configuration details for providers and frameworks such as OpenAI, Amazon Bedrock, and LangChain, including customized messages and model parameters such as temperature and tokens. It is your application’s responsibility to pass this information to the AI provider or framework.

The LaunchDarkly AI SDKs provide methods to help you track how your AI model generation is performing, and in some cases, these methods take the completion from common AI providers as a parameter. However, it is still your application’s responsibility to call the AI provider. To learn more, read Tracking AI metrics.

To request a new model, click the Give feedback option and let us know what models you’d like to have included.

Privacy and personally identifiable information (PII)

LaunchDarkly does not send any of the information you provide to any models, and does not use any of the information to fine tune any models.

You should follow your own organization’s policies regarding if or when it may be acceptable to send end-user data either to LaunchDarkly or to an AI provider. To learn more, read AgentControl and information privacy.