langchain-tools
npx machina-cli add skill a5c-ai/babysitter/langchain-tools --openclawLangChain Tools Skill
Capabilities
- Create custom LangChain tools with proper schemas
- Integrate existing tools and APIs
- Design tool descriptions for optimal LLM understanding
- Implement structured tool inputs with Pydantic
- Handle tool errors and fallbacks
- Create tool chains and pipelines
Target Processes
- custom-tool-development
- function-calling-agent
Implementation Details
Tool Creation Patterns
- @tool decorator: Simple function-based tools
- StructuredTool: Tools with complex input schemas
- BaseTool subclass: Full control over tool behavior
- Tool from functions: Dynamic tool creation
Configuration Options
- Tool name and description
- Input schema (args_schema)
- Return type specification
- Error handling strategy
- Async/sync execution modes
Best Practices
- Clear, action-oriented descriptions
- Explicit input parameter documentation
- Proper error messages for LLM understanding
- Idempotent operations where possible
Dependencies
- langchain-core
- pydantic
Source
git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/ai-agents-conversational/skills/langchain-tools/SKILL.mdView on GitHub Overview
This skill lets you build custom LangChain tools with proper schemas, integrate existing APIs, and craft descriptions that improve LLM understanding. It covers common patterns like the @tool decorator, StructuredTool, and BaseTool subclassing, along with error handling and tool chaining to create robust agent capabilities.
How This Skill Works
Tools are created using multiple patterns: @tool for simple functions, StructuredTool for complex inputs, BaseTool for full control, and Tool from functions for dynamic creation. Each tool specifies an input schema (args_schema) and a return type, plus an error handling strategy and optional async or sync execution. Tools are then registered and orchestrated by LangChain agents and can be linked into tool chains.
When to Use It
- You need a custom reusable action encapsulated as a tool that calls an API or performs a calculation
- You are building an agent that uses function calling to invoke tools
- You want structured inputs with clear parameters using a schema like args_schema
- You aim to compose several tools into a processing pipeline or workflow
- You must implement consistent error handling and fallbacks for tool failures
Quick Start
- Step 1: Define the tool pattern you will use such as tool decorator or StructuredTool and create the input schema
- Step 2: Implement the tool logic, specify the return type, and add explicit error handling
- Step 3: Register the tool with your LangChain setup and wire it into an agent or tool chain
Best Practices
- Write clear, action oriented tool descriptions
- Document explicit input parameters with an input schema
- Provide robust and user friendly error messages for the LLM
- Design idempotent operations where possible
- Test tools across sync and async modes and simulate failures during QA
Example Use Cases
- Create a simple tool with a decorator pattern to fetch current weather data
- Wrap a REST API as a StructuredTool to retrieve user profile information
- Implement a BaseTool subclass with retry logic and timeout handling
- Create a dynamic tool using Tool from functions for runtime capabilities
- Chain tools to fetch data, transform it, and present a summary to the user