Skip to main content
Complete reference for the Laddr tool configuration schema.

Tool Definition

Laddr tools are Python functions decorated with @tool. Parameter schemas are automatically generated from function signatures, so you don’t need to manually define JSON schemas.

Basic Tool

With Pydantic Model

For complex validation, use a Pydantic BaseModel as the first parameter:

Minimal Tool (Auto-inferred)

If you omit name and description, they’re inferred from the function:

@tool Decorator Parameters

Note: Parameter schemas are automatically generated from function signatures. You don’t need to manually define JSON schemas.

Parameter Descriptions

name

Rules:
  • Must be unique and descriptive
  • Use lowercase snake_case
  • Avoid generic names
  • If omitted, uses function name
Examples:

description

Best Practices:
  • Begin with an action verb
  • Limit to 100 characters
  • Avoid redundant phrasing like “use this tool to…”
  • If omitted, uses first line of docstring
Examples:

trace

Enables or disables trace logging. Example:
Set to False when:
  • Handling sensitive user data
  • Reducing log volume for high-frequency tools

trace_mask

Redacts specified fields in traces. Example:
Fields matching these keys will appear as ***REDACTED*** in logs.

Automatic Schema Generation

Parameter schemas are automatically generated from Python function signatures. The system maps Python types to JSON Schema types:

Type Hints Examples

Supported Type Annotations

  • Basic types: str, int, float, bool
  • Collections: list[T], dict, tuple
  • Optional: Optional[T] or T | None
  • Union: str | int (maps to first type)
  • Pydantic Models: Full validation support
Note: Type annotations are optional but recommended for better schema generation.

Complete Examples

Example 1: Basic Tool

Generated Schema:

Example 2: With Pydantic Validation

Example 3: API Wrapper Pattern

Example 4: Data Transformer

Example 5: File Operations


Return Format

Tools should return dictionaries with a consistent format:
Status Values:
  • "success" - Tool executed successfully
  • "error" - Tool execution failed

Registering Tools with Agents

Tools must be registered with agents. There are several ways to do this:

Method 1: Direct Registration

Method 2: Auto-Discovery

Tools are automatically discovered from agents.<agent_name>.tools package:
The agent automatically loads all @tool decorated functions from this package.

Method 3: Using bind_tools

Tool Registry

Tools are managed through a ToolRegistry that supports:
  • Registration: Add tools with optional aliases
  • Lookup: Find tools by name or alias
  • Listing: Get all available tools
  • Validation: Automatic input validation via Pydantic

Testing Tools

Manual Testing (Python)

Testing via API

Returns all tools with their schemas:

Best Practices

  1. Use Type Hints: Always annotate function parameters for better schema generation
  2. Descriptive Names: Use clear, action-oriented tool names (web_search not search)
  3. Error Handling: Always return consistent error format
  4. Sensitive Data: Use trace_mask for API keys, tokens, passwords
  5. Pydantic for Complex: Use Pydantic models for complex validation needs
  6. Documentation: Write clear docstrings (used as descriptions if not provided)

Common Patterns

Pattern: API Wrapper

Pattern: Data Transformer

Pattern: File Operations

Next Steps