This guide shows how to connect an Amazon Bedrock-powered application to LaunchDarkly AgentControl. Amazon Bedrock provides a single API for multiple foundation models with enterprise-grade AWS integration. By the end, you will be able to manage your model configuration and prompts outside of your application code, and track metrics automatically.
AgentControl supports two modes:
instructions string. Use it when your runtime or framework expects a goal/instructions input for a structured workflow. Agent mode changes the configuration shape from messages to instructions. Your application maps these instructions into your provider or framework’s native input.Both modes support tool calling. This guide walks through completion mode as the main path, with an optional agent config section. To learn more about when to use each mode, read When to use completion mode vs agent mode.
This guide provides examples in both Python and Node.js (TypeScript).
If you’re new to AgentControl, start with the Quickstart and return to this guide when you are ready for a more detailed 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 need the following:
bedrock-runtime:Converse permission.Before you begin, review these key concepts.
An AgentControl config is a LaunchDarkly resource that controls how your application uses large language models. Each AgentControl config contains one or more variations. Each variation specifies:
You can update these settings in LaunchDarkly at any time without changing your application code.
A context represents the end user interacting with your application. LaunchDarkly uses context attributes to:
{{ ldctx.* }} placeholders in your prompts with context attribute valuesOther placeholders, such as {{ topic }}, are populated from the variables argument you pass at runtime.
When you retrieve an AgentControl config, call createTracker() (Node.js) or create_tracker() (Python) on the returned object to mint a tracker. The tracker records metrics from your Bedrock calls, including:
These metrics appear on the AI Insights dashboard in LaunchDarkly.
Install the LaunchDarkly AI SDK and the AWS Bedrock SDK in your application. AgentControl is supported by LaunchDarkly server-side SDKs only. The Node.js examples in this guide use the server-side Node.js AI SDK.
Here is how to install the required packages:
Create a .env file in your project root to store your credentials:
Add .env to your .gitignore to keep credentials out of version control.
Initialize both the LaunchDarkly client and the Amazon Bedrock runtime client. Store your credentials in environment variables.
Here is the initialization code:
Create an AgentControl config in the LaunchDarkly UI to store your Bedrock model settings and prompts.
If you have the LaunchDarkly MCP server or agent skills configured, prompt your coding assistant to create the AgentControl config for you. For example:
“Create a completion mode AgentControl config called ‘Bedrock assistant’ with a ‘Claude Sonnet 4’ variation using the us.anthropic.claude-sonnet-4-20250514-v1:0 Bedrock model, temperature 0.7, max_tokens 1024, and the system message: ‘You are a helpful assistant. Answer questions about {{topic}}.’ Enable targeting.”
To create the AgentControl config:
To create a variation:
us.anthropic.claude-sonnet-4-20250514-v1:0.temperature to 0.7 and max_tokens to 1024.
To enable targeting:

Retrieve the AgentControl config from LaunchDarkly by calling the completion config function. Pass a context that represents the current user. You can also pass an optional fallback configuration that the SDK uses when LaunchDarkly is unreachable.
Here is how to get the AgentControl config:
The SDK uses the fallback configuration when LaunchDarkly is unreachable. Check the enabled property and handle the disabled case in your application.
For production use:
The Amazon Bedrock Converse API expects a specific format. System messages go in a top-level system list, user and assistant messages go in the messages array with nested content blocks, and model parameters go in inferenceConfig. The tracker’s track_bedrock_converse_metrics helper records latency, success, errors, and token usage directly from the Converse response.
Define a helper to filter AgentControl config parameters to Bedrock’s inferenceConfig shape. Bedrock’s Converse API accepts maxTokens, temperature, topP, and stopSequences. Rename LaunchDarkly’s max_tokens key to maxTokens; the rest already match.
Then call Bedrock with the config and pass the response to the tracker:
Agent-mode AgentControl configs return a single instructions string instead of a message list, and they let you attach reusable tools from the LaunchDarkly tools library. With Bedrock’s Converse API, the instructions map to a system content block and tools pass through on the toolConfig parameter.
First, define the tool in LaunchDarkly so the AgentControl config variation can reference it:
get_order_status as the Key.

us.anthropic.claude-sonnet-4-20250514-v1:0.max_tokens to 1024.get_order_status.
To learn more about managing tools, read Tools in AgentControl.
Use agent_config() instead of completion_config(). The SDK returns attached tools under parameters.tools in OpenAI’s type=function shape, so convert them to Bedrock Converse’s {toolSpec: {name, description, inputSchema: {json}}} shape and pass them on the toolConfig parameter. Tool handler functions stay in your application code: LaunchDarkly stores the schema, your application owns the behavior.
In completion mode, you can attach judges to variations in the LaunchDarkly UI for automatic evaluation. In agent mode, invoke judges programmatically through the AI SDK.
To learn more, read When to use completion mode vs agent mode and Agents in AgentControl.
Use the LaunchDarkly UI to monitor how your applications are performing across all AgentControl configs and for individual 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 AI Insights.
To view metrics for a specific AgentControl config:
The dashboard displays the following metrics:
Metrics update approximately every minute. Use these metrics to compare variations and optimize your prompts. To learn more, read Monitor AgentControl configs.

The AI SDKs emit OpenTelemetry-compatible spans for each generation call. You can forward these spans to your existing observability stack for deeper analysis. To learn more, read Observability and LLM observability.
Close the LaunchDarkly client when your application shuts down to flush pending events.
Here is how to close the client:
For short-lived applications such as scripts, explicitly flush events before closing.
Here is how to flush events:
Here is a complete working example that combines all the steps.
After you have the basic integration working, you can extend it with:
For more AgentControl guides, read the other guides in the AgentControl guides section.
If you are experiencing problems with your configuration, this section lists common errors and solutions.
If metrics do not appear on the AI Insights dashboard:
track_bedrock_converse_metrics in Python, trackBedrockConverseMetrics in Node.js).flush() before closing the client, especially for short-lived scripts.If the LaunchDarkly SDK fails to initialize:
If you always receive the fallback configuration:
If you receive Amazon Bedrock API errors:
bedrock-runtime:Converse permission.In this guide, you connected an Amazon Bedrock-powered application to LaunchDarkly AgentControl. You can now: