Module 3 · Lesson 2 of 6
Tool calling explained
How a model asks for a tool, how your code runs it, and how read and write permissions keep a brokerage safe.
9 min
A model on its own can only write text. It cannot check a calendar, look up a listing or update a CRM. Tool calling is the mechanism that lets it ask for those things in a structured way, so that your software can do them and hand back the result. Every agent you will build in this course, from a showing assistant to a lead router, rests on it.
For a brokerage, tool calling is also where risk lives. A tool that reads a calendar is harmless. A tool that sends an email to a seller, or changes a price in the CRM, is not. Knowing how tool calls work lets you decide which tools an AI may use freely and which ones need a person to say yes.
What a tool definition is
- Key term
- Tool definition
A short description you give the model of one action it may request: the tool's name, what it does and when to use it, and the inputs it needs. The inputs are written as a schema, a precise list of fields and their types.
Here is a tool definition for a showing assistant at Maple & Main Realty (fictional). You will never need to type one from memory: a coding agent, an SDK or an automation tool writes this for you. But you should be able to read one.
{
"name": "check_showing_availability",
"description": "Check open showing slots for one listing on one day. Use before suggesting times to a client. Does not book anything.",
"input_schema": {
"type": "object",
"properties": {
"listing_id": { "type": "string", "description": "Brokerage listing ID, e.g. MM-2026-0142" },
"date": { "type": "string", "description": "Day to check, YYYY-MM-DD" },
"duration_minutes": { "type": "integer", "description": "Length of showing, 30 or 60" }
},
"required": ["listing_id", "date"]
}
}
Read it line by line:
nameis what the model writes when it wants this tool. Short, specific and verb-first works best.descriptionis the most important line. The model decides whether to use a tool almost entirely from this sentence. Say what it does, when to use it, and what it does not do.input_schemalists the inputs. Each has a type (text, whole number, true or false) and its own short description.requirednames the inputs the model must always supply. Here, a listing and a date; duration is optional.
Some vendors call these "functions" and the process "function calling". It is the same idea.
How a tool call actually happens
The model never runs the tool. It asks, your code runs it, and the result goes back. Four messages make one tool call.
- 1. TriggerYour app sends the message plus the tool list
- 2. AIModel replies with a tool request, not text
- 3. ToolYour code checks the request and runs it
- 4. DataYour code sends the result back
- 5. AIModel uses the result to answer or ask for another tool
- You send the user's message, your instructions, and the list of tool definitions.
- The model replies with a tool request instead of a normal answer, for example: use
check_showing_availabilitywithlisting_id"MM-2026-0142" anddate"2026-10-27". - Your code runs it. It checks the request makes sense, calls the showing system, and gets a result such as "Open: 11:00, 15:30, 17:00".
- You send the result back, and the model either answers ("11:00 and 15:30 are open") or asks for another tool. That is the agent loop from the previous lesson.
Because step 3 is your code, it is also your checkpoint. Before running anything, the harness can check that the listing ID exists, that the date is not in the past, and that the person using the assistant is allowed to see that listing.
The model can be wrong about the inputs
A model can invent a listing ID or misread a date. Good harnesses validate every tool request against the schema and against real data before running it, and send back a clear error ("No listing MM-2026-0999") so the model can correct itself.
Read tools and write tools
The single most useful habit in agent design is to sort every tool into one of two piles.
- Key term
- Read tool and write tool
A read tool looks something up and changes nothing. A write tool changes something in the world: it sends, books, creates, updates, deletes or pays.
| Tool | Read or write | Risk if the AI gets it wrong | Sensible default |
|---|---|---|---|
search_listings | Read | Shows the wrong homes | Allow freely |
check_showing_availability | Read | Suggests a slot that is taken | Allow freely |
get_contact from the CRM | Read, personal information | Exposes a client's details to the wrong user | Allow only for the assigned agent's contacts |
draft_email | Write, but only a draft | A bad draft sits in the drafts folder | Allow; a human sends |
request_showing | Write | Books a showing the seller did not approve | Ask every time |
send_sms | Write, client-facing | Sends a wrong or non-compliant message | Ask every time, check consent |
update_listing_price | Write, regulated | Advertises a wrong price | Do not give this tool to an agent |
Notice the middle ground: personal information. Reading a client's file changes nothing, but it is still sensitive under PIPEDA, so who may read what matters as much as who may write. Module 11 covers privacy in depth.
Permissions: where the rules live
There are three layers of permission, and a safe design uses all three.
- Which tools exist at all. If the agent has no delete tool, it cannot delete. Leaving a tool out is the strongest control there is.
- Ask before running. Most harnesses let you mark tools as "always allow", "ask each time" or "never". Claude Desktop, Claude Code, Cursor and n8n all offer some version of this, as of October 2026.
- What the tool's own login can do. A tool uses an account or key to reach the CRM or inbox. Give that key the narrowest access the job needs: read-only where possible, one mailbox not all, one team's contacts not the whole brokerage.
Write permissions into the harness and the accounts, not only into the prompt. "Never book without asking" in a prompt is a request; a tool marked "ask each time" is a lock.
In practice
Maple & Main Realty wants a website assistant that answers questions about its listings and helps visitors request a showing. Devon, who runs operations, lists the tools before anyone builds anything.
search_listings(city, max_price, beds) READ allow
get_listing(listing_id) READ allow (public fields only)
check_showing_availability(listing_id, date) READ allow
request_showing(listing_id, slot, name, email, phone)
WRITE creates a request in the CRM,
listing agent must confirm
send_email / send_sms not given to this agent
The assistant can search, explain and propose times without anyone watching. When a visitor picks a slot, request_showing creates a pending request, not a confirmed booking, and the listing agent confirms it. The assistant never sends messages itself; the CRM's normal confirmation process does that, with the brokerage's consent records attached. One more choice: get_listing returns only public listing fields, so the assistant cannot reveal seller notes or lockbox codes even if a visitor asks cleverly.
Common mistakes
- Vague descriptions such as "Gets data". The model cannot choose well between tools it cannot tell apart.
- One giant tool that does everything (
crm_action). Split it into small read and write tools so each can have its own permission. - Letting the model's inputs flow straight into a live system without checking them.
- Returning unhelpful errors ("Error 500") instead of a sentence the model can act on.
- Connecting tools with an admin account because it was quickest to set up.
Key takeaways
- A tool definition is a name, a plain description and an input schema. The description drives the model's choice.
- The model only asks. Your code or harness runs the tool and returns the result, which is your chance to check it.
- Sort every tool into read or write. Allow reads freely (mindful of personal information); put writes behind approval or leave them out.
- Enforce permissions in three places: which tools exist, ask-before-running settings, and the access of the account each tool uses.
Finished reading? Move on when you're ready.