Tool Configuration
This page provides comprehensive documentation for configuring tools in PraisonAI, including timeout settings, performance optimization, error handling, and resource management.In YAML the field name is still
tool_timeout:; in Python pass tool execution settings through tool_config=ToolConfig(timeout=…). The standalone tool_timeout, tool_retry_policy, and parallel_tool_calls kwargs were removed and raise TypeError.Tool Timeout Configuration
Basic Timeout Settings
Consolidated ToolConfig (new in PraisonAI 0.0.6x)
PraisonAI now provides a unifiedToolConfig dataclass that consolidates tool-related parameters into a single configuration object. This replaces the previous pattern of separate tool_timeout, parallel_tool_calls, and tool_retry_policy parameters.
ToolConfig Options
Artifact Storage
Whenenable_artifacts=True, tool outputs that exceed output_limit are saved to disk and the agent gains tools to page through them on demand — preventing silent data loss for large web scrapes, file reads, or query results.
Artifact Storage
Full documentation: how overflow is stored, the six retrieval tools the agent gains, storage layout, and best practices.
Configuration Shortcuts
ToolConfig supports convenient shorthand notation:Removed legacy kwargs
The standalonetool_timeout, parallel_tool_calls, and tool_retry_policy keyword arguments on Agent(...) have been removed. Passing them raises TypeError:
tool_config=ToolConfig(...) instead.
YAML and the CLI are unaffected —
tool_timeout: in YAML and --tool-timeout on the CLI remain valid; the wrapper translates them into a ToolConfig before constructing the Agent.
Agent-Level Tool Timeout
Each agent can settool_config=ToolConfig(timeout=…) (or tool_config=True for defaults) which applies to all tool executions. When a tool times out, it returns a standardized error dict:
- Each agent has its own 2-thread tool executor (reused across calls)
- Timed-out tools return
{"error": "Tool timed out after Ns", "timeout": True}rather than raising - Thread names are prefixed
tool-<agent_name>— useful for debugging
Why the change?
The consolidation groups timeout + retry + parallel execution settings into one config object instead of three loose kwargs. This provides better organization and prevents parameter conflicts.For complete concurrency control documentation including per-agent limits and sync/async patterns, see Concurrency.
Wrapper-Level Tool Timeout (YAML / CLI — Defense-in-Depth)
When you settool_timeout in YAML (framework: praisonai) or pass --tool-timeout on the CLI, the wrapper now wraps every tool callable with a timeout-enforcing shim before handing the agent to the SDK.
This means the tool_timeout knob is enforced even if the downstream SDK ignores it, even if the tool is a blocking C extension, and even if the tool is a subprocess that does not honour CancelledError.
The wrapper handles sync and async tools differently:
- Sync tools run in an instance-owned
ThreadPoolExecutor(see_get_tool_timeout_executorinagents_generator.py); on timeout the future is best-effort cancelled. A call that already started cannot be interrupted, so the worker may keep running. - Async tools are wrapped with
asyncio.wait_for(...), which cancels the underlying task cleanly.
ToolTimeoutError (a TimeoutError subclass), not a JSON dict. This preserves each tool’s declared return-type contract — a typed return value is never silently downgraded to a string. Framework adapters catch it and translate it per framework.
ToolTimeoutError carries three attributes:
Crucially, the wrapper also keeps passing
tool_timeout to the SDK Agent, so both layers are active — hence “defense in depth”. The SDK’s executor catches the common case; the wrapper catches the pathological one.
Example usage:
fetch_url blocks for more than 15 s, the wrapper raises ToolTimeoutError instead of hanging indefinitely; the framework adapter catches it and translates it into a value its framework understands, so the crew keeps moving.
Precedence note: Three timeout layers can apply, in different units:
When more than one applies, the shortest effective timeout wins in practice — whichever fires first short-circuits the tool call. The three layers are independent, so mind the units:
tool_timeout_ms: 5000 equals a 5-second wrapper tool_timeout: 5. See Tool Call Executor Timeout for the millisecond layer.
Which value the wrapper uses
The wrapper resolves a single effective timeout per invocation:
Boolean YAML values (
tool_timeout: yes, tool_timeout: true) are explicitly ignored — they used to be silently coerced to a 1-second cap because bool subclasses int. Use integers or floats (e.g. tool_timeout: 30).
PRAISONAI_TOOL_TIMEOUT_WORKERS caps the named thread pool that runs sync tools under timeout (default 32). Invalid or non-positive values fall back to 32 with a warning log line. Once half the pool’s workers are permanently leaked to stuck sync tools, the pool is automatically recycled: leaked threads continue until their syscall returns, but new tool calls get a fresh pool instead of queueing behind them.Advanced Timeout Configuration
Dynamic Timeout Calculation
Performance Tuning
Resource Management
Tool Execution Strategies
Performance Monitoring
Tool-Specific Configurations
Web Scraping Tools
Database Tools
API Tools
File Processing Tools
Error Handling Configuration
Resource Pooling
Complete Tool Configuration Example
Environment Variables
For comprehensive tool whitelisting and collision prevention, see the Allowed Tools feature documentation.
Best Practices
Timeout Guidelines
-
Set appropriate timeouts based on tool type
- Fast operations: 5-15 seconds
- API calls: 15-30 seconds
- Web scraping: 30-60 seconds
- Data processing: 60-300 seconds
-
Use dynamic timeouts for variable workloads
-
Always set connection timeouts lower than read timeouts
Performance Optimization
- Enable caching for idempotent operations
- Use connection pooling for repeated operations
- Circuit breakers for tools are automatic - see Tool Circuit Breaker
- Monitor and alert on performance degradation
See Also
- Tool Development - Creating custom tools
- Agent Configuration - Agent-level tool settings
- Best Practices - Configuration guidelines

