Skip to content

Automatic Generation of Agents and Tools

A key feature of the Youtu-Agent framework is its ability to automate the creation of both tools and agent configurations. This streamlines the development process and reduces the need for manual boilerplate code and configuration.

Automatic Tool Generation

The framework provides a script to scaffold a new tool, including its configuration file and a dedicated virtual environment.

1. Generate the Tool

Run the following command to start the tool generation process:

python scripts/gen_tool.py

This script will create a new directory (configs/tools/generated/{name}) and configuration file (configs/tools/generated/{name}.yaml). It will also automatically create a virtual environment for the new tool and install its dependencies by running the following commands in the new directory:

cd {output_directory}
uv venv
source .venv/bin/activate
uv pip install -r requirements.txt

2. Test the Generated Tool

After generating a tool, you can test it in two ways:

Method 1: Unit Testing

You can write a dedicated unit test for your new tool.

Note

You will need to modify the example test file tests/meta/test_tool_generator.py to match the specifics of your generated tool before running the test.

pytest tests/meta/test_tool_generator.py

Method 2: Interactive Chat

You can test the tool by interacting with an agent that has the tool enabled.

Note

You must first update the agent configuration at configs/agents/meta/example.yaml to include and properly configure your new tool.

python scripts/cli_chat.py --config meta/example --stream

Automatic Agent Generation

Youtu-Agent can also automatically generate a configuration for a SimpleAgent based on your requirements. This is handled by an interactive "meta-agent" that asks you questions to define the agent's name, instructions, and desired tools.

1. Generate the Agent Configuration

Start the interactive generation process by running:

python scripts/gen_simple_agent.py

The script will guide you through the setup process and save the resulting configuration file in the configs/agents/generated/ directory.

2. Run the Generated Agent

Once the configuration is created, you can run your new agent using the cli_chat.py script. Be sure to replace xxx with the name of your generated config file.

python scripts/cli_chat.py --stream --config generated/xxx