Agentic Research

Tool call

Also: function calling · 函式呼叫 · 工具使用 · tool use

The model does not act; it requests action by returning structured text saying "call this tool with these arguments".

When you will meet it

It is the only mechanism by which an agent acts. Grasping that the model requests and YOUR code executes stops you imagining the AI reached into your system by itself.

An analogy

Like a prescription. The doctor cannot fetch the medicine himself; he writes an order and the pharmacist executes it. If the order is wrong, the pharmacist has to catch it.

Minimal example

// 模型回傳的東西(簡化)
{
  "tool_calls": [{
    "id": "call_abc123",
    "function": {
      "name": "read_file",
      "arguments": "{\"path\": \"notes.txt\"}"
    }
  }]
}
// 注意:這時檔案還沒被讀。要你的程式去讀。

arguments is a model-generated string: it may be malformed JSON or point at a file that does not exist. Validate before executing.

What people get wrong

  • Executing arguments without validating them. The most common hole in agent systems.
  • Assuming one round trip suffices. It takes at least two: out to request, back to feed the result in and ask again.

Related terms

Next