Tools
Tools extend LLM capabilities by allowing models to execute actions and retrieve information.
Built-in Tools
The SDK includes 6 built-in tools for common operations:
import { getBuiltinTools } from '@agentic-work/sdk/tools';
const tools = getBuiltinTools();
// [shellTool, readFileTool, writeFileTool, listFilesTool, deleteFileTool, searchTool]Shell Tool
Execute shell commands:
import { shellTool } from '@agentic-work/sdk/tools';
// Tool definition
// name: 'shell'
// args: { command: string, workDir?: string }
// returns: stdout/stderr outputRead File Tool
Read file contents:
Write File Tool
Write or create files:
List Files Tool
List directory contents:
Delete File Tool
Delete files:
Search Tool
Search files with regex:
Creating Custom Tools
With Zod Schema
With JSON Schema
Tool Interface
Tool Context
The execution context provides useful utilities:
Using Context
MCP Tools from Platform
Access platform MCP tools:
Tool Result Format
Tools should return strings. For structured data, use JSON:
Error Handling in Tools
Return errors as structured responses:
Or throw errors to be caught by the agent:
Best Practices
Clear descriptions - Help the LLM understand when to use the tool
Typed schemas - Use Zod for runtime validation
Descriptive parameters - Add
.describe()to Zod fieldsHandle cancellation - Check
context.signal.abortedfor long tasksReport progress - Use
context.onProgressfor visibilityReturn JSON - Structure outputs for easy parsing
Handle errors gracefully - Return meaningful error messages
Last updated