Skip to main content

Module optimizer

Module optimizer 

Source
Available on crate feature eval only.
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:

  1. Evaluate the agent against the eval set to get a baseline score
  2. If the score already meets the target threshold, report “no optimization needed”
  3. Otherwise, ask the optimizer LLM to propose improved instructions
  4. Apply the best improvement and re-evaluate
  5. Repeat until max iterations or target threshold is reached
  6. 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§

OptimizationResult
Result of a prompt optimization run.
OptimizerConfig
Configuration for the prompt optimization loop.
PromptOptimizer
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.