Quick Start
Simple Agent with Dynamic Tool
Use the
@tool decorator with dynamic_schema_overrides to create a tool whose schema changes based on runtime state.How It Works
The override function is called every time the agent needs tool definitions, ensuring schemas always reflect current runtime state.| Component | Purpose |
|---|---|
| Override Function | Updates schema based on current configuration |
| Registry | Manages tools and applies overrides on each read |
| Base Schema | Original tool parameter structure |
| Runtime State | Current limits, API keys, or other dynamic values |
Common Patterns
Pattern A: Concurrency Limits
Reflect runtime concurrency settings in parameter constraints.Pattern B: API Key Filtering
Show only services with valid API keys in enum options.Pattern C: Live Status Updates
Include current quotas or status information in tool descriptions.Best Practices
Keep Override Functions Fast and Pure
Keep Override Functions Fast and Pure
Override functions run on every schema read, so avoid expensive operations like network calls or file I/O. Cache expensive computations and update them periodically rather than computing on each schema request.
Return Fresh Dict Objects
Return Fresh Dict Objects
Always return a new dictionary rather than mutating the input schema. The base schema is already a deep copy, but your modifications should create new objects to avoid side effects.
Handle Failures Gracefully
Handle Failures Gracefully
If your override function raises an exception, the tool falls back to its base schema with a warning logged. Don’t rely on the override for critical functionality—it should enhance the schema, not make it functional.
Use Decorator Form for Simple Functions
Use Decorator Form for Simple Functions
Prefer the
@tool(dynamic_schema_overrides=...) decorator for plain functions. Only subclass BaseTool when you need richer lifecycle methods or complex state management.Related
Tools Overview
Learn about PraisonAI’s tool system and how to create custom tools
Agents Guide
Understand how agents use tools and manage their capabilities

