Function class represents a tool that can be called by an agent. It includes the function definition, parameters, hooks, and execution logic.
Core Fields
Name of the function (must be a-z, A-Z, 0-9, underscores, or dashes, max 64 chars).
Description of what the function does, used by the model to choose when to call it.
JSON Schema object describing function parameters.
Enable strict schema validation (for structured outputs).
The actual function to be called.
Instructions
Additional instructions for using the function.
If True, adds instructions to the agent’s system message.
Display & Control
If True, the function call result is shown along with sending it to the model.
If True, the agent stops after executing this function.
Hooks
Hook that runs before the function is executed.
Hook that runs after the function is executed (success or failure).
List of hooks to run around tool calls as middleware.
HITL (Human-in-the-Loop)
If True, requires user confirmation before execution.
If True, requires user input before execution.
List of fields that should be provided by the user.
If True, the function will be executed outside the agent’s control.
Approval type: “required” (blocking) or “audit” (non-blocking).
Caching
Enable result caching.
Directory to store cache files.
Cache time-to-live in seconds.