feat: add optimization for duration#128
Open
andrewklatzke wants to merge 1 commit intoaklatzke/AIC-2118/add-additional-validation-to-chaos-modefrom
Open
feat: add optimization for duration#128andrewklatzke wants to merge 1 commit intoaklatzke/AIC-2118/add-additional-validation-to-chaos-modefrom
andrewklatzke wants to merge 1 commit intoaklatzke/AIC-2118/add-additional-validation-to-chaos-modefrom
Conversation
jsonbailey
approved these changes
Apr 9, 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 additional instructions and data so that the variation generation can optimize for speed when prompted to. Uses a regex of various words ("speed" "snappy" etc.) that inform the prompt whether or not to do the duration optimization.
Describe alternatives you've considered
This could be added as a top-level option to the prompt (to optimize this specific dimension) but I think that would quickly explode into a ton of options. Instead I'm just relying on the users' intent with the acceptance statement to determine whether or not to include the instructions.
Duration tolerance might be tweaked in the future/made an option, but for now this achieves the request in the PRD.
Additional context
Example (abridged) output when including "make it faster" in the prompt:
Note
Medium Risk
Adds a new latency-based pass/fail gate and injects timing context into judge/variation prompts, which can change when optimizations succeed and may increase retries/iterations when timing data is present.
Overview
Adds duration-aware optimization that activates when any judge
acceptance_statementcontains latency keywords (via new_acceptance_criteria_implies_duration_optimization).When active, the client now (1) passes
agent_duration_msinto acceptance-statement judges so they can reference current vs baseline latency in their rationale, (2) includes per-iterationduration_msin variation-generation prompt history plus an extra Duration Optimization section, and (3) enforces a new duration gate (_evaluate_duration) requiring candidates to be <0.80 * baseline(history[0]) in chaos, validation, and ground-truth sample evaluation.Adds extensive tests covering keyword detection, judge instruction injection, duration gating edge cases, and end-to-end wiring in both chaos and ground-truth modes.
Reviewed by Cursor Bugbot for commit 5d76276. Bugbot is set up for automated code reviews on this repo. Configure here.