Agents and Tools
AI & ML: lesson 14 of 15
A model in a loop that can act and try again.
Lesson 14 of 15 · 5 min
Agents and Tools
Step 1 of 12
An agent is a model in a loop with tools. You describe each tool: name, purpose, parameters.
The Idea
An agent is a model in a loop with tools. You describe each tool — name, purpose, parameters — and the model answers with a structured call instead of prose. Your code runs it, returns the result, and the loop repeats.
Real-World Example
A field surveyor with a radio. When the map disagrees with the ground, they call the office for one measurement, wait for the number to come back, and only then carry on drawing.
The Tradeoff
Tools break the model out of its training data and its shaky arithmetic. Every extra step also multiplies latency, cost, and the chance of one wrong turn compounding into five. Loops need hard caps and tools need permission checks, because fetched text can try to steer the agent.
Your turn
Fill in the blank.
def get_invoice(invoice_id):
return {"id": invoice_id, "total": 90}
tools = {"get_invoice": get_invoice}
call = {"name": "get_invoice", "arguments": {"invoice_id": "INV-42"}}
# hand the model's arguments to your function
result = tools[call["name"]](___)
print(result) # want {'id': 'INV-42', 'total': 90}Mini quiz
1 / 3