Building agents
Implement the tool loop with validation, limits and human confirmation.
Updated on Aug 09, 2026
An agent runs a controlled loop: it sends messages and tools to the model, receives a function request, validates and runs the action, returns the result, and repeats until it reaches a final answer.
- 1
Declare small tools
Use specific names, objective descriptions and parameters constrained by JSON Schema.
- 2
Validate before running
Treat arguments as untrusted input. Check types, permissions and limits.
- 3
Return the result
Include the tool message with the matching
tool_call_id. - 4
Enforce limits
Set a maximum number of steps, a timeout, retries and a budget.
- 5
Confirm high-impact actions
Require human approval before charging, deleting, publishing or sending.
Start with HiNova for general use. Consider HiMax when the workflow requires planning, many constraints or complex analysis; consider HiGenesis for simple, repeatable, high-volume tools. The final decision should come from your own tests.
- Log calls, tools, arguments, results, cost and duration.
- Use idempotency for repeatable actions.
- Return structured errors so the model can correct course.
- Block data and tools outside the user's scope.
- Test success, refusal, timeout, retry and empty results.
- Provide a safe exit for the step limit.
Implement function calling
See the fields and the message loop in the API reference.

