MODULE 05 // 18:20

The Tool-Calling Execution Cycle

Implement the request-dispatch-observation loop that allows a stateless LLM to interact with stateful external systems.

// KEY ARCHITECTURAL TAKEAWAYS

  • Write ergonomic tool descriptions that minimize parameter hallucination.
  • Return actionable error messages so the model can self-correct invalid arguments.
  • Enforce idempotency keys on mutating tool calls.
REFERENCE IMPLEMENTATION // SNIPPET
{
  "name": "query_dns_zone",
  "description": "Resolve A, AAAA, CNAME, or TXT records for a target hostname.",
  "parameters": {
    "type": "object",
    "properties": {"hostname": {"type": "string"}, "record_type": {"type": "string"}},
    "required": ["hostname"]
  }
}