Skip to main content
Agent Optimization provides a structured, iterative approach to refining AI-generated outputs by systematically improving prompts. With the agent-opt Python library, you can programmatically enhance your prompts by adjusting their structure based on evaluation-driven feedback. This library empowers you to move beyond manual trial-and-error, offering advanced algorithms to achieve higher-quality, more consistent, and more efficient LLM responses.

Why Use the agent-opt Library for Optimization?

The agent-opt library provides access to state-of-the-art optimization algorithms that go beyond simple prompt variations:
  • Advanced Algorithms: Access to 6+ distinct optimization strategies (Bayesian Search, Meta-Prompt, ProTeGi, GEPA, Random Search, PromptWizard).
  • Few-Shot Learning: Automatically select and format optimal examples for few-shot tasks.
  • Iterative Refinement: Systematic improvement through multiple rounds of evaluation and prompt modification.
  • Reproducibility: Programmatic control allows for versioning and tracking of optimization experiments.
  • Cost Efficiency: Smart evaluation strategies and targeted search methods help minimize API calls.
This section covers:
  • Why optimization is essential for improving response clarity, consistency, and efficiency.
  • How optimization differs from experimentation and when to use each approach.
  • Step-by-step guidance on running optimizations using the Python SDK.
  • Deep dives into each optimizer to help you choose the right strategy.

Prompt Optimization Fundamentals

Learn about optimization fundamentals and explore different optimization algorithms.

Using the Python SDK

Programmatic optimization with advanced algorithms.