Skip to main content
Tool availability gating filters unavailable tools at schema-build time, preventing the LLM from hallucinating calls to tools that can’t run.
The user requests work that needs a gated tool; unavailable tools are hidden from the schema so the model cannot call them.

Quick Start

1

Decorator with Availability Check

2

Class-Based Tool with Availability


How It Works

PhaseBehaviorPerformance
Schema BuildAvailability checks run onceZero runtime cost
Tool ExecutionOnly available tools includedNo availability overhead
LLM InteractionOnly sees usable toolsPrevents hallucination

Implementation Methods

Function Decorator

BaseTool Protocol

Registry Functions


Availability Rules

Behavior Patterns

  1. No Check Method: Tool is always considered available
  2. Check Returns True: Tool included in LLM schema
  3. Check Returns False: Tool hidden from LLM
  4. Check Throws Exception: Tool hidden + warning logged

Exception Handling

Plain Function Registry


Configuration Patterns

Environment-Based Availability

Service Discovery

Conditional Tool Loading


Best Practices

Availability checks run at schema-build time and must be fast (< 100ms recommended).Good: Environment variable checks, import tests, quick pings Bad: Full API calls, heavy file operations, long network requests
For checks that might be expensive, consider caching results.
Check critical dependencies first, avoid unnecessary work.
Design tools to degrade gracefully when dependencies are partially available.

Tools Overview

Core tool system and registration

Agent Configuration

Agent setup and tool integration