langchain-react-agent
npx machina-cli add skill a5c-ai/babysitter/langchain-react-agent --openclawFiles (1)
SKILL.md
1.3 KB
LangChain ReAct Agent Skill
Capabilities
- Implement ReAct (Reasoning + Acting) agent patterns using LangChain
- Configure tool binding and function calling for agents
- Design thought-action-observation loops
- Integrate with various LLM providers (OpenAI, Anthropic, etc.)
- Handle agent memory and state persistence
- Implement error handling and retry logic for agent actions
Target Processes
- react-agent-implementation
- function-calling-agent
Implementation Details
Core Components
- Agent Executor Setup: Configure LangChain AgentExecutor with appropriate settings
- Tool Integration: Bind tools with proper schemas and descriptions
- Prompt Engineering: Design system prompts for ReAct reasoning patterns
- Output Parsing: Parse agent outputs and handle structured responses
Configuration Options
- LLM model selection and parameters
- Tool definitions and schemas
- Memory type (buffer, summary, vector)
- Max iterations and timeout settings
- Verbose/debug mode configuration
Dependencies
- langchain
- langchain-openai / langchain-anthropic
- Python 3.9+
Source
git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/ai-agents-conversational/skills/langchain-react-agent/SKILL.mdView on GitHub Overview
Implements the LangChain ReAct pattern (Reasoning + Acting) using tool binding for iterative decision making. It supports memory persistence, error handling, and multi-LLM integration to automate reasoning and actions.
How This Skill Works
Core components include Agent Executor Setup, Tool Integration with schemas, and Output Parsing. The agent uses a designed system prompt to guide ReAct reasoning, calls bound tools via function calling, and parses structured outputs to determine next steps.
When to Use It
- You need a ReAct-style agent that alternates between thinking and performing actions by calling bound tools.
- You want to bind tools with clear schemas (Read, Write, Edit, Bash, Glob, Grep) and enable function calls.
- You require memory and state persistence across sessions.
- You need error handling with retries and timeouts for actions.
- You want configurable LLM providers, iteration limits, and verbose debugging.
Quick Start
- Step 1: Install LangChain and required dependencies (e.g., langchain, langchain-openai, langchain-anthropic) and ensure Python 3.9+.
- Step 2: Bind tools (Read, Write, Edit, Bash, Glob, Grep) with schemas and configure an AgentExecutor for a ReAct loop.
- Step 3: Run the agent with a system prompt, observe the thought-action loop, and tune max iterations and timeout as needed.
Best Practices
- Start with a minimal tool set and clear tool schemas before expanding.
- Design system prompts to tightly guide the ReAct reasoning pattern.
- Implement precise output parsing to distinguish thoughts, actions, and results.
- Choose a memory strategy (buffer, summary, or vector) and size limits wisely.
- Add robust error handling and retry logic with backoff for unreliable actions.
Example Use Cases
- KB helper: reads knowledge articles with Read and writes notes with Write to a knowledge base.
- Code assistant: uses Bash and Glob to locate files, reads them, and applies Edits as needed.
- Log analyzer: runs Grep to extract patterns and writes summaries for reporting.
- File organizer: leverages Bash commands to move and organize files using Glob patterns.
- Research summarizer: reads multiple sources and writes concise summaries for decision makers.
Frequently Asked Questions
Add this skill to your agents