The function-calling loop
Tools turn a model into an agent. The loop is:
1. Model sees tools
2. Model asks for one
3. You run it safely
4. Send result back
5. Repeat until done
Only allow tools the user would actually want. A model with a delete_database tool is a serious risk.
Sandboxing tool calls
Run every tool behind a permission check:
if tool.name in TOOL_PERMISSIONS[role]:
run(tool)
else:
escalate()
Tools are power. Scope each tool to who can use it.
Log every call with arguments so you can review what the agent did and why.