feat: adds ability to optimize for cost#172
Open
andrewklatzke wants to merge 2 commits intoaklatzke/AIC-2263/sdk-dx-improvementsfrom
Open
feat: adds ability to optimize for cost#172andrewklatzke wants to merge 2 commits intoaklatzke/AIC-2263/sdk-dx-improvementsfrom
andrewklatzke wants to merge 2 commits intoaklatzke/AIC-2263/sdk-dx-improvementsfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ 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 94de596. Configure here.
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
Implements cost optimization in the same manner as latency optimization. Searches the acceptance statement for keywords pertaining to token usage/cost (e.g. costs, pricing, bill) and adds instructions to the variation generation to try to optimize for costs. Additionally has the acceptance statement prompt return instructions for the variation generation (ie, cheaper model, etc).
Describe alternatives you've considered
This is a feature addition.
Additional context
We'll be adding UI options for both latency and cost with adjustable thresholds, but these are still valid once those arrive since a mention of cost/latency means the user is trying to optimize for it.
Note
Medium Risk
Adds new cost estimation and pass/fail gating that can change optimization outcomes and variation generation behavior; relies on model pricing metadata being present/accurate and introduces new tolerance thresholds.
Overview
Adds cost optimization alongside existing latency optimization by detecting cost-related keywords in acceptance statements and injecting cost-focused guidance into judge instructions and variation-generation prompts.
Tracks per-iteration
estimated_cost_usd(computed from token usage + model pricing) inOptimizationContext, surfaces it in prompt feedback, and adds a_evaluate_costgate (default 20% improvement vs baseline) that is applied in normal runs, validation, and ground-truth mode when cost optimization is implied.Also tightens a few behaviors: treats
token_limit=0as “no limit”, prefetches/stores model configs for pricing lookup, and limits placeholder-restoration to the active variable set while downgrading related logs from warning to debug.Reviewed by Cursor Bugbot for commit dc82818. Bugbot is set up for automated code reviews on this repo. Configure here.