feat: ability to specify variation key on config or from_options for optimization package#162
Open
andrewklatzke wants to merge 1 commit intoaklatzke/AIC-2263/sdk-dx-improvementsfrom
Conversation
…optimization package
jsonbailey
approved these changes
May 5, 2026
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
Introduces a new code path that fetches AI config variations via the LaunchDarkly REST API (including model/tools overrides) and changes validation behavior when
variation_keyis set, so misconfiguration or API errors can now fail runs earlier.Overview
Adds support for pinning an optimization run to a specific AI Config variation via a new
variation_keyoption (andvariationKeyin config-driven runs), instead of always using the SDK-evaluated variation.When provided,
_get_agent_confignow fetches the requested variation over the REST API (newLDApiClient.get_ai_config_variation) and uses itsinstructions,tools, andmodelConfigKeyas the optimization baseline; callers now enforce thatLAUNCHDARKLY_API_KEYandproject_keyare set for this path. Tests are expanded to cover the new option wiring, API behavior, and error propagation.Reviewed by Cursor Bugbot for commit c5e39eb. Bugbot is set up for automated code reviews on this repo. Configure here.