
Langchain
Scaffold LangChain agents with ReAct loops, bound tools, and streaming when you are turning an LLM into an action-taking product feature.
Install
npx skills add https://github.com/orchestra-research/ai-research-skills --skill langchainWhat is this skill?
- Documents the ReAct pattern: reasoning, tool execution, observation, and repeat until done
- create_agent examples with Claude Sonnet and optional OpenAI ChatOpenAI models
- Starter tools pattern (calculator, search) and system_prompt wiring for tool use
- Covers agent components with emphasis on the model as the reasoning engine and temperature settings
- Runnable invoke snippet with messages API shape for quick validation
Adoption & trust: 1 installs on skills.sh; 9.4k GitHub stars; 2/3 security scanners passed (skills.sh audits).
Recommended Skills
Microsoft Foundrymicrosoft/azure-skills
Azure Aimicrosoft/azure-skills
Azure Hosted Copilot Sdkmicrosoft/azure-skills
Lark Eventlarksuite/cli
Running Claude Code Via Litellm Copilotxixu-me/skills
Setup Matt Pocock Skillsmattpocock/skills
Journey fit
Primary fit
Agent construction is core Build work; the guide centers on create_agent, tools, and invoke patterns rather than launch or ops runbooks. Content maps directly to agent-tooling: model selection, tool definitions, system prompts, and the reason-act-observe loop.
Common Questions / FAQ
Is Langchain safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Langchain
# LangChain Agents Guide Complete guide to building agents with ReAct, tool calling, and streaming. ## What are agents? Agents combine language models with tools to solve complex tasks through reasoning and action: 1. **Reasoning**: LLM decides what to do 2. **Acting**: Execute tools based on reasoning 3. **Observation**: Receive tool results 4. **Loop**: Repeat until task complete This is the **ReAct pattern** (Reasoning + Acting). ## Basic agent creation ```python from langchain.agents import create_agent from langchain_anthropic import ChatAnthropic # Define tools def calculator(expression: str) -> str: """Evaluate a math expression.""" return str(eval(expression)) def search(query: str) -> str: """Search for information.""" return f"Results for: {query}" # Create agent agent = create_agent( model=ChatAnthropic(model="claude-sonnet-4-5-20250929"), tools=[calculator, search], system_prompt="You are a helpful assistant. Use tools when needed." ) # Run agent result = agent.invoke({ "messages": [{"role": "user", "content": "What is 25 * 17?"}] }) print(result["messages"][-1].content) ``` ## Agent components ### 1. Model - The reasoning engine ```python from langchain_openai import ChatOpenAI from langchain_anthropic import ChatAnthropic # OpenAI model = ChatOpenAI(model="gpt-4o", temperature=0) # Anthropic (better for complex reasoning) model = ChatAnthropic(model="claude-sonnet-4-5-20250929", temperature=0) # Dynamic model selection def select_model(task_complexity: str): if task_complexity == "high": return ChatAnthropic(model="claude-sonnet-4-5-20250929") else: return ChatOpenAI(model="gpt-4o-mini") ``` ### 2. Tools - Actions the agent can take ```python from langchain.tools import tool # Simple function tool @tool def get_current_time() -> str: """Get the current time.""" from datetime import datetime return datetime.now().strftime("%H:%M:%S") # Tool with parameters @tool def fetch_weather(city: str, units: str = "fahrenheit") -> str: """Fetch weather for a city. Args: city: City name units: Temperature units (fahrenheit or celsius) """ # Your weather API call here return f"Weather in {city}: 72°{units[0].upper()}" # Tool with error handling @tool def risky_api_call(endpoint: str) -> str: """Call an external API that might fail.""" try: response = requests.get(endpoint, timeout=5) return response.text except Exception as e: return f"Error calling API: {str(e)}" ``` ### 3. System prompt - Agent behavior ```python # General assistant system_prompt = "You are a helpful assistant. Use tools when needed." # Domain expert system_prompt = """You are a financial analyst assistant. - Use the calculator for precise calculations - Search for recent financial data - Provide data-driven recommendations - Always cite your sources""" # Constrained agent system_prompt = """You are a customer support agent. - Only use search_kb tool to find answers - If answer not found, escalate to human - Be concise and professional - Never make up information""" ``` ## Agent types ### 1. Tool-calling agent (recommended) Uses native function calling for best performance: ```python from langchain.agents import create_tool_calling_agent, AgentExecutor from langchain.prompts import ChatPromptTemplate # Create prompt prompt = ChatPromptTemplate.from_messages([ ("system", "You are a helpful assistant"), ("human", "{input}"), ("placeholder", "{agent_scratchpad}"), ]) # Create agent agent = create_tool_calling_agent( llm=model, tools=[calculator, search], prompt=prompt ) # Wrap in executor agent_executor = AgentExecutor( agent=agent, tools=[calculator, search], verbose=True, max_iterations=5, handle_parsing_errors=True ) # Run result = agent_executor.invoke({"input": "What is the weather in Paris?"}) ``` ### 2. ReAct agent (reasoning trace) Show