Skip to content

# L1: Your First Agent ​

Build a single-tool agent from scratch.

Module: M1 Foundations
Est. Time: 60 min
Files: `starter.py`, `solution.py`

## Objective ​

Create an agent that reads a file and answers questions about its contents.

## Concepts ​

- LLM + Tools + Loop = Agent
- Tool definition with input schema
- The agent loop (think → act → observe → repeat)
- The `reasoning` parameter

## Starter ​

bash

    cd course/labs/L1-first-agent/
    python starter.py test.txt "What is this file about?"

The starter has TODO markers where you fill in:

1. Define the `read_file` tool schema
2. Implement the `execute_tool` function
3. Implement the `run_agent` loop
4. Wire up the main entry point

## Solution ​

bash

    python solution.py test.txt "What is this file about?"

Compare your implementation against the solution. Key differences to check:

- Did you set `MAX_ITERATIONS`?
- Does every tool call include `reasoning`?
- Does the loop terminate on `end_turn`?

## Checkpoints ​

1. Tool call is made correctly (schema matches)
2. Tool result is fed back to the LLM
3. LLM produces final answer using tool result
4. Loop terminates (doesn't run forever)