feat: ability to specify variation key on config or from_options for optimization package#162
Merged
andrewklatzke merged 3 commits intoJul 14, 2026
Conversation
…optimization package
jsonbailey
approved these changes
May 5, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fba29aa. Configure here.
f0c4612
into
aklatzke/AIC-2263/sdk-dx-improvements
5 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Requirements
Describe the solution you've provided
Adds the ability to specify a specific variation when setting up your configuration within LaunchDarkly, or specify a specific variation key in the
from_optionsmethod as long as the API key is present. This allows a user to optimize against a specific variation rather than the default.Describe alternatives you've considered
This is a relatively straightforward feature request. Allowing users to specify a specific variation cuts down on toil of managing your agents in the UI (don't need to change targeting or create a dummy config).
Additional context
This is purely additive. Functionality for configs not using the variation key, or that don't have it set, is unchanged -- it will continue using the default pulled via the SDK.
Note
Medium Risk
Changes which agent instructions/model/tools seed an optimization run; wrong variation_key or API failures abort the run, but default behavior when unset is unchanged.
Overview
Adds
variation_keysupport so optimization can start from a named LaunchDarkly AI config variation instead of the SDK’s context-evaluated default.When
variation_keyis set (onOptimizationOptions/GroundTruthOptimizationOptions, orvariationKeyon the remote agent optimization config),_get_agent_configloads that variation through a newLDApiClient.get_ai_config_variationbeta REST call and uses its instructions, tools, and model (modelConfigKeyplus optional parameters). An optional reusedapi_clientavoids extra clients inoptimize_from_config. Missing variations surfaceLDApiErrorwith no SDK fallback.optimize_from_options, ground-truth options, andoptimize_from_configforward the key and enforce API key +project_keywhen it is set. Tests cover the API client, agent config wiring, and entry points.Note:
dataclasses.pycurrently declaresvariation_keytwice on both options types (duplicate field definitions in the diff)—worth cleaning before merge.Reviewed by Cursor Bugbot for commit bc2508e. Bugbot is set up for automated code reviews on this repo. Configure here.