# Module 2: Tutorial - Running Agents with the Aurite CLI Welcome to the next step in your Aurite journey! In the previous tutorials, you learned how to configure agents in JSON files and run them using a Python script. Now, you'll learn a more direct and powerful way to interact with your agents: the **Aurite Command-Line Interface (CLI)**. The CLI allows you to run any agent defined in your project's configuration without writing or modifying any Python code. **Learning Objectives:** * Understand the client-server nature of the Aurite CLI. * Learn how to start the Aurite API server. * Understand the purpose of the `run-cli execute agent` command. * Successfully execute a pre-configured agent by connecting to the running API. * Gain confidence in using the CLI as a primary way to test and interact with your agents. --- ## Prerequisites Before you start, ensure you have: 1. **Completed Module 1 & the Notebooks:** You should have a project initialized and be familiar with the basic concepts. 2. **Project Directory:** You should have an Aurite project created (e.g., `my_local_project`). 3. **Active Virtual Environment:** Make sure you are in your project directory (`cd my_local_project`) and your Python virtual environment is active. 4. **Environment Variables Set:** Your `.env` file in your workspace root must contain your `OPENAI_API_KEY`. --- ## Tutorial Steps The `run-cli` command works by communicating with a running Aurite API server. This means you will need two terminals open for this tutorial: one for the server and one for the client (the `run-cli` command). ### 1. Start the Aurite API Server 1. **Open Terminal 1:** * Navigate to your project directory (e.g., `cd my_local_project`). * Make sure your virtual environment is active. 2. **Run the `start-api` command:** * This command starts the web server that loads your project's configuration and makes your agents available. ```bash start-api ``` 3. **Observe the Output:** * You will see logs indicating the server has started, usually ending with a line like: ``` INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) ``` * **Leave this terminal running.** This server must remain active to receive requests from the CLI. ### 2. Run an Agent with the CLI Now, with the server running, you can execute an agent from a second terminal. 1. **Open Terminal 2:** * Navigate to the **same** project directory. * Activate the **same** virtual environment. 2. **Execute the Agent:** * Run the following command in your second terminal: ```bash run-cli execute agent "My Weather Agent" "What is the weather like in San Francisco?" ``` * **Command Breakdown:** * `run-cli execute agent`: This is the command to execute a specific agent via the API. * `"My Weather Agent"`: The name of the agent to run. This must match an agent loaded by the API server. * `"What is the weather like in San Francisco?"`: This is the user message sent to the agent. 3. **Observe the Output:** * In **Terminal 1** (the server), you will see new log messages showing that it received a request to run the agent and started the `weather_mcp_server.py`. * In **Terminal 2** (the client), you will see the final response from the agent printed to the console: ``` The weather in San Francisco is 18°C with Foggy conditions. ``` * Once the command is finished, you can shut down the server in Terminal 1 by pressing `CTRL+C`. --- ## Success Criteria / Verification You've successfully completed this tutorial if: * In Terminal 1, the `start-api` command ran successfully and the server started. * In Terminal 2, the `run-cli execute agent` command executed without errors. * The server logs (Terminal 1) show the `weather_server` was started. * The client (Terminal 2) printed a weather forecast for San Francisco. --- **Congratulations!** You have now mastered a second, more direct way to execute your agents. Using the CLI is an excellent way to quickly test agents, run them in scripts, or integrate them into larger automated systems. * **Recap:** * **Tutorial 1:** You learned to **configure** agents and run them via a Python script. * **Tutorial 2:** You learned to **execute** any pre-configured agent directly from the **CLI**. You are now well-equipped with the foundational skills to build and run your own custom agents and tools.