Skip to main content
AI Agents and Tooling·Lesson 2 of 5

Tools and Function Calling

Tool or function calling lets the model emit structured requests your server executes — search, create ticket, query database. You stay in control of what can actually run.

Design tools narrowly

Prefer several small tools over one "do anything" endpoint. Each tool should:

  • Have a JSON schema (or equivalent) for arguments.
  • Declare errors the model might need to recover from.
  • Avoid overlapping responsibilities with other tools.

Validate everything

The model may hallucinate parameter values. Validate types, enums, and IDs server-side. Reject and return a clear error message the model can use to self-correct.

Idempotency and side effects

For writes, use idempotency keys where applicable so retries do not double-charge or duplicate records.

Returning observations

Return concise, structured results — not raw HTML dumps — unless summarization is unavoidable. Large observations bloat context and cost.

Key takeaways

  • Tools are your real API surface — treat them like public endpoints.
  • Schema + validation beats trusting natural language arguments.
  • Shape tool output for the next model turn: short, typed, actionable.