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
reasoningparameter
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:
- Define the
read_filetool schema - Implement the
execute_toolfunction - Implement the
run_agentloop - 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
- Tool call is made correctly (schema matches)
- Tool result is fed back to the LLM
- LLM produces final answer using tool result
- Loop terminates (doesn't run forever)