Module 5 – Tool Calling and the Responses/Agent Loop
Learning outcomes
Build an agent loop that calls typed tools, validates arguments, handles failures, and stops predictably.
Agent loop
- Send instructions, user input, and available tool schemas.
- The model returns text, structured output, or tool calls.
- The application validates the tool name and arguments.
- Authorization and approval checks run before side effects.
- The application executes the tool and returns a bounded result.
- The loop continues until a final answer, limit, error, or approval pause.
Production controls
- Strict JSON schemas and server-side validation
- Idempotency keys for retryable writes
- Timeouts, concurrency limits, and maximum agent turns
- Allowlisted tools and least-privilege credentials
- Human approval for destructive, financial, publishing, or permission-changing actions
Lab 5
Create three tools: search documentation, read an issue, and draft a change plan. Keep all tools read-only. Add schema validation, timeouts, and a maximum of six agent turns.