Skip to content

Commit 27b248e

Browse files
committed
chore: line lengths
1 parent f481ed3 commit 27b248e

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

packages/optimization/src/ldai_optimizer/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def _trim_history(
179179
return history
180180
return history[-max_len:]
181181

182+
182183
# Maps SDK status strings to the API status/activity values expected by
183184
# agent_optimization_result records. Defined at module level to avoid
184185
# allocating the dict on every on_status_update invocation.
@@ -194,7 +195,6 @@ def _trim_history(
194195
}
195196

196197

197-
198198
class OptimizationClient:
199199
_options: OptimizationOptions
200200
_ldClient: LDAIClient

packages/optimization/src/ldai_optimizer/dataclasses.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ class OptimizationContext:
221221
duration_ms: Optional[float] = None # wall-clock time for the agent call in milliseconds
222222
usage: Optional[TokenUsage] = None # token usage reported by the agent for this iteration
223223
estimated_cost_usd: Optional[float] = None # estimated cost; USD when pricing available, else total tokens
224-
accumulated_token_usage: Optional[int] = None # single running total across ALL calls in this run (generation + judges + variation)
224+
# single running total across ALL calls in this run (generation + judges + variation)
225+
accumulated_token_usage: Optional[int] = None
225226

226227
def copy_without_history(self) -> OptimizationContext:
227228
"""

packages/optimization/src/ldai_optimizer/prompts.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ def build_new_variation_prompt(
183183
history, model_choices, variable_choices, initial_instructions
184184
),
185185
variation_prompt_duration_optimization(model_choices) if optimize_for_duration else "",
186-
variation_prompt_cost_optimization(model_choices, quality_already_passing=quality_already_passing) if optimize_for_cost else "",
186+
variation_prompt_cost_optimization(
187+
model_choices, quality_already_passing=quality_already_passing
188+
) if optimize_for_cost else "",
187189
]
188190

189191
return "\n\n".join(s for s in sections if s)
@@ -628,10 +630,13 @@ def variation_prompt_cost_optimization(
628630
"## Cost Optimization:",
629631
"The acceptance criteria for this optimization implies that token usage / cost should be reduced.",
630632
"*** IMPORTANT: All quality acceptance criteria are currently passing. ***",
631-
"The goal of this variation is to reduce cost WITHOUT changing the behavior or quality of the agent's responses.",
633+
"The goal of this variation is to reduce cost WITHOUT changing the behavior or quality"
634+
" of the agent's responses.",
632635
"Do NOT alter the instructions in ways that would change what the agent says or how it reasons.",
633-
"Only apply changes that reduce token usage or switch to a cheaper model while preserving the same output quality.",
634-
"If you cannot reduce cost without risking quality, keep the instructions unchanged and only consider a cheaper model.",
636+
"Only apply changes that reduce token usage or switch to a cheaper model while preserving"
637+
" the same output quality.",
638+
"If you cannot reduce cost without risking quality, keep the instructions unchanged and"
639+
" only consider a cheaper model.",
635640
"",
636641
]
637642
else:
@@ -650,14 +655,16 @@ def variation_prompt_cost_optimization(
650655
"- Remove redundant, verbose, or repeated phrasing from the instructions.",
651656
"- Collapse multi-sentence explanations into a single concise directive.",
652657
"- Remove examples or few-shot demonstrations unless they are essential for accuracy.",
653-
"- Eliminate instructional scaffolding that the model does not need (e.g. 'You are a helpful assistant that...').",
658+
"- Eliminate instructional scaffolding that the model does not need"
659+
" (e.g. 'You are a helpful assistant that...').",
654660
"- Use bullet points instead of prose where possible — they are more token-efficient.",
655661
"",
656662
"### Reducing token usage (output tokens):",
657663
"- Instruct the agent to be concise and avoid unnecessary elaboration.",
658664
"- Specify the exact format and length of the expected response (e.g. 'Respond in one sentence.').",
659665
"- Set or reduce max_tokens if the current value allows longer responses than needed.",
660-
"- Avoid instructions that encourage the agent to 'explain its reasoning' unless required by the acceptance criteria.",
666+
"- Avoid instructions that encourage the agent to 'explain its reasoning' unless required"
667+
" by the acceptance criteria.",
661668
"",
662669
"### Reducing per-token cost via model selection:",
663670
"- Consider switching to a cheaper model from the available choices if quality requirements can still be met.",

0 commit comments

Comments
 (0)