2026-11-22 · Prompt Tutorials
Many people use GLM as a fancy Q&A machine, but its real strength is agent capability: letting the model decide when to call tools, when to reason, and when to assemble everything into a final answer. This guide walks you through from zero, with steps you can follow directly in the playground and on the BigModel API platform.
Simply put: agent = model + tools + loop. When the model reads your request and realizes it needs external information (search, calculation, database lookup), it issues a tool call. Your program executes the tool, feeds the result back, and the model decides whether to call again or produce the final answer. Tool calling is a native capability across the GLM series — no trick prompts required.
The GLM-5 flagship series is steadier at planning complex multi-step tasks and long tool chains, while the GLM-4 multimodal family brings in image understanding for mixed tasks like "look at this chart and research it." Instruction following is reliable in both Chinese and English, which makes things easy for global users.
No code needed. Open the web playground and build a math-and-lookup assistant. Tell it about its tools in the system prompt, ask questions in natural language, and watch whether it chooses to call a tool. Copy this template:
You are a math and lookup assistant with access to these tools: 1. calculator(expression): evaluates math expressions, e.g. (3+5)*12 2. web_search(query): searches up-to-date public information Rules: - For any calculation, call calculator. Do not compute in your head. - For time-sensitive info (prices, news, weather), call web_search. - Before each call, state in one sentence why you need the tool. - After receiving results, summarize the answer concisely in the user's language.
Then ask: "Calculate the total price of 128 items at 25% off, and look up the current USD/CNY exchange rate." You'll see it explain its intent, make the call, then summarize. That rhythm — explain, call, summarize — is the core feel of an agent.
The playground is for experiencing; shipping requires the API. On BigModel, tool calling follows the common function calling convention: you declare a tool list in the request, the model returns tool_calls, you execute them, append the results as messages, and start the next round. Parameter details follow the official documentation. This system prompt template works broadly:
You are a task-oriented agent whose goal is to complete the user's task. Available tools: - search(query): search for information - run_code(code): execute Python code Workflow: 1. Break the task into steps first. 2. At each step, decide: if a tool is needed, call it directly — never fabricate tool results. 3. If a tool call fails, retry at most 2 times, then try a different approach. 4. Once all information is gathered, output the final answer as: [Answer] one-sentence conclusion [Process] no more than 5 bullet points Forbidden: giving conclusions that require external data without calling a tool.
The loop logic is three lines: if you receive tool_calls, execute them and append the results; if not, the task is done and you exit; set a max round count (say 10) to prevent infinite loops. Open-weight GLM versions support the same flow in local deployments, handy for teams building private agents.
One: writing "do not fabricate tool results" in the prompt noticeably reduces made-up data. Two: write tool descriptions precisely — parameters and return formats included — and wrong-tool selections drop sharply. Three: run complex tasks on the GLM-5 flagship, lighter ones on smaller GLM-4 family models to control cost; Coding Plan subscribers can experience agent-style multi-step operations directly in coding scenarios. Four: for mixed Chinese-English tasks, keep the system prompt in one language and declare the output language separately for steadier results.
From one tool call in the playground to one loop over the API — agent onboarding really is just these two steps. Get these two templates running and you're already ahead of most chat-box-only users. What tools you plug in next is entirely up to you.
本文为使用方法整理,内容选自网上公开资料,供参考;本站为非官方资讯站,产品能力以官方页面为准。