Expand description
Prompt optimization engine.
Iteratively improves an agent’s system instructions using an optimizer LLM
and an evaluation set. Used by the adk optimize CLI command.
§Overview
The PromptOptimizer runs an optimization loop:
- Evaluate the agent against the eval set to get a baseline score
- If the score already meets the target threshold, report “no optimization needed”
- Otherwise, ask the optimizer LLM to propose improved instructions
- Apply the best improvement and re-evaluate
- Repeat until max iterations or target threshold is reached
- Write the best-performing instructions to the output file
§Example
ⓘ
use adk_eval::optimizer::{PromptOptimizer, OptimizerConfig};
use std::sync::Arc;
let optimizer = PromptOptimizer::new(
optimizer_llm,
evaluator,
OptimizerConfig::default(),
);
let result = optimizer.optimize(agent, &eval_set).await?;
println!("Final score: {}", result.final_score);Structs§
- Optimization
Result - Result of a prompt optimization run.
- Optimizer
Config - Configuration for the prompt optimization loop.
- Prompt
Optimizer - Iteratively improves an agent’s system instructions using an optimizer LLM and an evaluation set.
Functions§
- run_
optimization_ loop - Run the core optimization loop with injectable evaluation and proposal functions.