Skip to content

feat: ability to specify variation key on config or from_options for optimization package#162

Merged
andrewklatzke merged 3 commits into
aklatzke/AIC-2263/sdk-dx-improvementsfrom
aklatzke/AIC-2371/allow-variation-selection
Jul 14, 2026
Merged

feat: ability to specify variation key on config or from_options for optimization package#162
andrewklatzke merged 3 commits into
aklatzke/AIC-2263/sdk-dx-improvementsfrom
aklatzke/AIC-2371/allow-variation-selection

Conversation

@andrewklatzke

@andrewklatzke andrewklatzke commented May 4, 2026

Copy link
Copy Markdown
Contributor

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

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_options method 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_key support so optimization can start from a named LaunchDarkly AI config variation instead of the SDK’s context-evaluated default.

When variation_key is set (on OptimizationOptions / GroundTruthOptimizationOptions, or variationKey on the remote agent optimization config), _get_agent_config loads that variation through a new LDApiClient.get_ai_config_variation beta REST call and uses its instructions, tools, and model (modelConfigKey plus optional parameters). An optional reused api_client avoids extra clients in optimize_from_config. Missing variations surface LDApiError with no SDK fallback.

optimize_from_options, ground-truth options, and optimize_from_config forward the key and enforce API key + project_key when it is set. Tests cover the API client, agent config wiring, and entry points.

Note: dataclasses.py currently declares variation_key twice 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.

@andrewklatzke andrewklatzke requested a review from jsonbailey May 4, 2026 22:36
@andrewklatzke andrewklatzke requested a review from a team as a code owner May 4, 2026 22:36

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread packages/optimization/src/ldai_optimizer/client.py
@andrewklatzke andrewklatzke merged commit f0c4612 into aklatzke/AIC-2263/sdk-dx-improvements Jul 14, 2026
5 checks passed
@andrewklatzke andrewklatzke deleted the aklatzke/AIC-2371/allow-variation-selection branch July 14, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants