← Back to concept explainers

Concept Fable

Tool calling

Conclusion first:Tool calling, also called Function Calling, is the mechanism by which a model requests external functions, APIs, databases, file systems, or business systems in a structured way to complete tasks. The model no longer just generates natural language suggestions; it outputs call requests that conform to a predefined schema, and the runtime checks parameters, permissions, and risks, then executes the tool and returns the result to the model. It is the key interface for an Agent to move from "being able to talk" to "being able to do."

Tool Calling, Function Calling · AI agent platform

Read the story first. There is no rush to give a definition here; let the question grow on its own first.

Fable

A doctor who only writes prescriptions walks into a pharmacy for the first time

In Qinghe Town there was a young doctor with very accurate analysis. When a patient said he was dizzy, he could determine whether the patient had caught a chill the night before; when a merchant said his chest felt tight, he could judge whether it was from days of traveling. The townspeople liked him because he explained things clearly and was very patient.

But after the clinic had been open for three months, trouble gradually appeared. The doctor could write many prescriptions a day, but the pharmacy was across the street. When patients took the prescriptions over, they often misread characters, missed dosages, or mixed the morning prescription with the afternoon's new one. The doctor had judged correctly, yet in the end the illness did not get better.

Some said this was not the doctor's problem but the patient's lack of care. So the clinic began writing prescriptions larger and more neatly. Indeed there were fewer errors, but new problems arose: some medicines needed to be decocted on the spot, some required checking inventory, and some could not be taken with other medicines. No matter how clearly the doctor wrote, he still did not know whether the pharmacy actually had the medicine at that moment.

Later the doctor tried writing more instructions on prescriptions: if there is no medicine A, use medicine B; if the patient has a fever, use half a qian less; if the pharmacy has a queue, fill urgent cases first. The prescriptions grew longer and longer, and the pharmacy clerks grew more and more afraid. Because they were not sure which words were suggestions, which were orders, and which situations required going back to ask the doctor.

On the day when something truly went wrong, a child arrived at the pharmacy holding two prescriptions at the same time. The old prescription said to continue taking the medication; the new prescription said to stop immediately. The pharmacy clerk asked: which one do we follow? The child said, both were written by doctors.

The mayor brought the doctor, the pharmacy shopkeeper and the assistant together. The shopkeeper said: We do not distrust the doctor; we just do not know when the doctor is explaining and when he is placing an order; we do not know which fields this order requires; we do not know whether an out-of-stock medicine can be substituted automatically; and we do not know who the result should be returned to after the prescription is filled.

So they remade a set of wooden tags. Each tag allowed only fixed fields: patient ID, medicine name, dosage, contraindications, whether substitution was allowed, whether clinic confirmation was required. After the pharmacy received a tag, it could only execute by field; after execution it had to stamp and return it; missing medicine, conflicts, or abnormal dosages all required sending the tag back to the doctor.

At first, the doctor felt the wooden board was too rigid. In the past, a casual sentence could express many things; now the intent had to be broken into explicit fields. But a few weeks later, the clinic became quiet. The pharmacy knew when to dispense, when to refuse, and when to ask for instructions. Patients no longer passed words around by guesswork. Only then did the doctor understand: what truly turns analysis into treatment is not writing the prescription more beautifully, but making the analysis issue requests in a way the pharmacy can understand, verify and be accountable for. Later the town added a night medicine cabinet. The doctor could not stay up until midnight, so the wooden board rules mattered even more: who could take medicine, how anomalies were returned, when results were stamped. The pharmacy did not treat long explanations as execution orders; it recognized only wooden boards with complete fields. The townspeople also saw clearly that only when request, execution and reporting can close the loop is collaboration reliable.

Reveal

This story is about: tool invocation

Tool calling, also called Function Calling, is the mechanism by which a model requests external functions, APIs, databases, file systems, or business systems in a structured way to complete tasks. The model no longer just generates natural language suggestions; it outputs call requests that conform to a predefined schema, and the runtime checks parameters, permissions, and risks, then executes the tool and returns the result to the model. It is the key interface for an Agent to move from "being able to talk" to "being able to do."

What matters is that it is not just a term, but a structural problem that repeatedly appears in real AI / Agent systems. Understanding it lets you judge when to add a model, when to change a process, and when to add governance.

Metaphor mapping

  • Young doctor: a large language model that can understand problems, generate solutions and make judgments
  • Prescription: natural language output looks clear, but is easily misread, missed, or over-interpreted
  • Pharmacy: external systems or tools, such as APIs, databases, search, email, CRM, file systems
  • Patient relaying messages: without tool calling, the gap between model output and real execution is bridged manually, which is error-prone
  • Prescriptions that get longer as you write: forcing execution flows with prompts and natural language explanations is hard to stabilize once complex
  • Fixed-slot wooden sign: function schema, specifying tool name, parameter fields, types and constraints
  • Pharmacy stamp return: tool execution results are returned to the model to form the basis for the next decision
  • Missing medication or abnormal dosage is sent back to the doctor: tool call failure, abnormal parameters, insufficient permissions, or need for manual confirmation
  • Analysis becomes treatment: model capabilities enter real business actions through tool calls

Andy Ren Xu's judgment

The practical value of this concept is that it helps you break "AI features that look smart" into deliverable, verifiable, and governable units of work.

Function schemaagent runtimeAPI callstructured outputpermissionstool result
京ICP备2026014272号