tools parameter; the model never runs anything itself. When it decides a tool would help, it replies with tool_calls, structured requests naming the function and its arguments, and pauses. Your code executes them and sends the results back, and the model writes its answer with those results in hand. Every model in the catalog supports tools.
What a tool call looks like
A response that requests tools hasfinish_reason: "tool_calls" and an assistant message shaped like this, note arguments is a JSON string to parse, not an object:
The full round trip
Three legs: request with tools → execute what the model asked for → send results back asrole: "tool" messages (one per call, echoing the tool_call_id):
Keep the assistant message containing
tool_calls in the history when you send the results, the tool messages answer it. Dropping it is the most common cause of confused follow-ups.From round trip to agent
An agent is this round trip in awhile loop: keep executing tool_calls and appending results until the model responds with plain content (or you hit your own step budget). The model may chain different tools across iterations to decompose a task, put the loop bound and any dangerous-action confirmation in your code, not in the prompt.
Best practices
- Write
descriptionfields like documentation for a new teammate, what the tool does, when to use it, what it returns. Tool choice quality tracks description quality. - Constrain arguments with JSON Schema:
enumfor closed sets,requiredfor mandatory fields, reject-and-retry beats guessing. - Return machine-readable results (JSON), and return errors as results too, a
{"error": "city not found"}tool message lets the model recover or ask the user, instead of the loop dying. - For latency-sensitive agents, start with GLM-5.3 Flash and move to DeepSeek V4 Pro 0813 when tasks need deeper reasoning between calls.