Skip to main content
Learn how the Lyzr ADK executes local tools during agent runs, including the execution flow, error handling, and best practices.

Execution Flow

When an agent runs with local tools:

LocalToolExecutor

The LocalToolExecutor manages tool execution with built-in error handling:

execute()

Returns: String result (JSON for dict/list, str for strings, str() for other types)

Error Handling

The executor never raises exceptions. All errors are returned as strings so the agent can handle them intelligently.

Tool Not Found

Execution Error

Missing Required Arguments


Result Serialization

The executor automatically serializes results:

Dict/List Results

String Results

Other Types


Async Support

Tools can be synchronous or asynchronous:

Sync Function

Async Function


Tool.execute()

Individual tools can also be executed directly:

No Function Error


Agent Integration

When tools are added to an agent, execution is automatic:

Execution Context

Accessing External Resources

Tools can access databases, APIs, and other resources:

Maintaining State

Use closures or classes for stateful tools:

Best Practices

Graceful Error Handling

Input Validation

Timeout Protection

Logging