$ lexprog.com

// notes from an old coder -- php, databases, and the occasional rant

[October 02, 2026] AI

Declare Tool Schemas as Tightly as a Public API

Tool JSON schemas should be as strict as an HTTP contract: required fields, enums, and no extra properties. Loose schemas produce unusable arguments.

────────────────────────────────────────────────────────

Declare Tool Schemas as Tightly as a Public API

Tip: Additional properties are not a feature

Tool JSON schemas should be as strict as an HTTP contract: required fields, enums, and no extra properties. Loose schemas produce unusable arguments.

{
  "name": "create_ticket",
  "parameters": {
    "type": "object",
    "additionalProperties": false,
    "required": ["title", "severity"],
    "properties": {
      "title": {"type": "string"},
      "severity": {"type": "string", "enum": ["low", "high"]}
    }
  }
}

Gotcha: Optional fields become hallucinated IDs

If ticket_id is optional, the model will invent one. Only include fields the tool can actually honor.

{"ticket_id": {"type": "string"}}  // drop this unless the API accepts it

Source: https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview

────────────────────────────────────────────────────────
<-- back to posts