Optimizing Custom Agents¶
This guide explains how to use AIAI CLI to optimize your own custom AI agents. While the demo agent is useful for learning, the real power of AIAI CLI comes from optimizing your own agent code.
Prerequisites¶
Before optimizing your custom agent, ensure:
- Your agent has a main entry point file
- The entry point file has a
main(inputs=None)
function that runs your agent with the provided inputs (theinputs
parameter is optional) - AIAI CLI is installed and configured
Creating an Entrypoint File¶
AIAI CLI requires a specific entrypoint file structure to interact with your agent. This file must:
- Have a
main(inputs=None)
function that accepts an optional input example - Run your agent with the provided inputs
- Return the agent's output
Here's what a minimal entrypoint file should look like:
# entrypoint.py
def main(inputs=None):
# Initialize your agent
agent = get_your_agent()
# Use the provided inputs or a default one
inputs = inputs or "Default inputs input here"
# Run your agent with the inputs
result = agent.run(inputs) # Or however your agent accepts inputs
# Return the result
return result
AIAI CLI will call this main()
function with different synthetic examples during optimization.
Preparing Your Agent¶
To prepare your agent for optimization:
- Document Dependencies: Ensure all dependencies are properly installed
- Test Your Agent: Make sure your agent runs correctly before optimization
Running the Optimization¶
To optimize your custom agent:
When prompted, provide the path to your agent's entry point file. AIAI CLI will:
- Validate your entrypoint file
- Analyze your agent's code
- Generate synthetic test data
- Run your agent with multiple examples
- Extract optimization rules
- Generate a comprehensive report