androidengineers.Book a session

Making models useful

Tools and agents in five minutes

article6 min

On its own, a model can only produce text. It cannot check today's weather, look up an order, or send an email. Tools change that — and when a model can choose which tools to use, step by step, you have an agent.

How tool calling works

You tell the model which tools exist and what they do. When it needs one, it does not run the tool itself. Instead, it replies with a request, like "please call get_order with order 1042". Your code runs the tool and sends the result back. Then the model continues.

User:   "Where is my order 1042?"
Model:  → requests tool: get_order(order_id="1042")
App:    runs get_order → "Shipped yesterday, arriving Friday"
Model:  "Your order shipped yesterday and should arrive on Friday."

This split is important: the model asks, your code decides. Your code can check whether the request is allowed before running anything.

From one tool call to an agent

An agent repeats that loop: look at the situation, choose a tool, see the result, choose again — until the task is done.

# academy-check
TOOLS = {"get_order": lambda order_id: "Shipped, arriving Friday"}

def model_decides(step):
    """Pretend model: first asks for a tool, then gives a final answer."""
    if step == 0:
        return {"tool": "get_order", "args": {"order_id": "1042"}}
    return {"answer": "Your order is arriving Friday."}

def run_agent(max_steps=3):
    for step in range(max_steps):          # a hard limit, so it can't loop forever
        decision = model_decides(step)
        if "answer" in decision:
            return decision["answer"]
        tool = TOOLS.get(decision["tool"])
        if tool is None:                    # only tools you allowed can run
            return "Stopped: unknown tool"
        tool(**decision["args"])
    return "Stopped: too many steps"

assert run_agent() == "Your order is arriving Friday."

Keep agents on a short leash

More freedom means more ways to go wrong. Good agents have:

  • Only the tools they need — a "read order" tool, not full database access.
  • Limits on steps, time, and cost.
  • Human approval before anything important or irreversible, like refunds or sending messages.

Often a simple fixed sequence ("look up the order, then reply") works better than a fully autonomous agent. Use an agent when the task genuinely needs it to decide what to do next.

You may also hear about MCP (Model Context Protocol), a standard way to connect models to tools and data — and A2A, a standard for agents talking to other agents. Both are covered in the Agentic AI path.

Try it: list three tools a "travel assistant" agent might need. Which one should require a human to approve before it runs?

Quick check: when a model "uses a tool", who actually runs it? (Your application code — the model only requests it.)

YOUR LEARNING JOURNEY

0 of 15 available lessons completed

Progress saved in this browser. No account needed.