langchain-2-agent-with-tools
Sub-skill of langchain: 2. Agent with Tools.
Best use case
langchain-2-agent-with-tools is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Sub-skill of langchain: 2. Agent with Tools.
Teams using langchain-2-agent-with-tools should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/2-agent-with-tools/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How langchain-2-agent-with-tools Compares
| Feature / Agent | langchain-2-agent-with-tools | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Sub-skill of langchain: 2. Agent with Tools.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 2. Agent with Tools
## 2. Agent with Tools
**ReAct Agent with Custom Tools:**
```python
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_react_agent
from langchain_core.tools import tool
from langchain import hub
from typing import Optional
import requests
import json
@tool
def calculate_mooring_tension(
depth: float,
line_length: float,
pretension: float,
offset: float
) -> str:
"""
Calculate approximate mooring line tension given parameters.
Args:
depth: Water depth in meters
line_length: Mooring line length in meters
pretension: Initial pretension in kN
offset: Horizontal vessel offset in meters
Returns:
Tension calculation result
"""
# Simplified catenary calculation
import math
suspended_length = math.sqrt(line_length**2 - depth**2)
stretch_factor = 1 + (offset / suspended_length) * 0.1
tension = pretension * stretch_factor
return json.dumps({
"horizontal_tension_kN": round(tension, 2),
"vertical_tension_kN": round(tension * (depth / line_length), 2),
"line_angle_deg": round(math.degrees(math.asin(depth / line_length)), 1)
})
@tool
def get_wave_data(location: str, date: Optional[str] = None) -> str:
"""
Get wave condition data for a location.
Args:
location: Location name or coordinates
date: Date in YYYY-MM-DD format (optional)
Returns:
Wave data including Hs, Tp, direction
"""
# Simulated data - replace with actual API call
wave_data = {
"location": location,
"significant_wave_height_m": 2.5,
"peak_period_s": 8.5,
"wave_direction_deg": 225,
"data_source": "simulated"
}
return json.dumps(wave_data)
@tool
def search_engineering_database(query: str) -> str:
"""
Search the engineering standards database.
Args:
query: Search query for standards/specifications
Returns:
Relevant standards and references
"""
# Simulated database - replace with actual search
results = {
"query": query,
"results": [
{"standard": "API RP 2SK", "title": "Design and Analysis of Stationkeeping Systems"},
{"standard": "DNV-OS-E301", "title": "Position Mooring"},
{"standard": "ISO 19901-7", "title": "Stationkeeping systems"}
]
}
return json.dumps(results)
def create_engineering_agent():
"""
Create an agent with engineering-specific tools.
"""
# Initialize LLM
llm = ChatOpenAI(model="gpt-4", temperature=0)
# Define tools
tools = [
calculate_mooring_tension,
get_wave_data,
search_engineering_database
]
# Get ReAct prompt from hub
prompt = hub.pull("hwchase17/react")
# Create agent
agent = create_react_agent(llm, tools, prompt)
# Create executor with error handling
agent_executor = AgentExecutor(
agent=agent,
tools=tools,
verbose=True,
handle_parsing_errors=True,
max_iterations=5
)
return agent_executor
# Usage
agent = create_engineering_agent()
response = agent.invoke({
"input": """
I need to analyze a mooring system in 100m water depth.
The lines are 350m long with 500kN pretension.
What would be the tension if the vessel offset is 15m?
Also, what standards should I reference?
"""
})
print(response["output"])
```
**Tool Agent with Structured Output:**
```python
from langchain_openai import ChatOpenAI
from langchain.agents import create_structured_chat_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_core.tools import tool
from pydantic import BaseModel, Field
from typing import List
class AnalysisResult(BaseModel):
"""Structured analysis result."""
summary: str = Field(description="Brief summary of findings")
key_findings: List[str] = Field(description="List of key findings")
recommendations: List[str] = Field(description="List of recommendations")
risk_level: str = Field(description="Risk level: low, medium, or high")
@tool
def analyze_document(document_path: str) -> str:
"""
Analyze an engineering document and extract key information.
Args:
document_path: Path to the document
Returns:
Extracted information from document
"""
# Simulated document analysis
return """
Document: Mooring Analysis Report
Key findings:
- Maximum tension: 2500 kN (within limits)
- Safety factor: 1.8 (above minimum 1.67)
- Fatigue life: 45 years (design life: 25 years)
Recommendations:
- Monitor chain condition at fairlead
- Consider dynamic analysis for extreme conditions
"""
def create_structured_agent():
"""Create agent that returns structured output."""
llm = ChatOpenAI(model="gpt-4", temperature=0)
tools = [analyze_document]
system_prompt = """You are an engineering analysis assistant.
Use the available tools to analyze documents and provide structured insights.
Always provide your final answer in a structured format with:
- summary
- key_findings (list)
- recommendations (list)
*Content truncated — see parent skill for full reference.*Related Skills
artifact-inline-no-tools-plan-review
Recover adversarial plan reviews on large or sandbox-hostile repos by embedding grounded facts + full plan text directly in a compact prompt and explicitly forbidding reviewer tool use.
scvi-tools
Deep learning for single-cell analysis using scvi-tools: data integration, batch correction, multi-modal analysis, reference mapping, and more.
devtools
Optimize development environment, containers, CLI productivity, and git workflows using Docker, shell tooling, and editor customization.
aqwa-batch-execution-integration-with-downstream-tools
Sub-skill of aqwa-batch-execution: Integration with Downstream Tools.
devtools-testing-devtools-skills
Sub-skill of devtools: Testing DevTools Skills.
devtools-git-advanced-workflows
Sub-skill of devtools: Git Advanced Workflows (+1).
devtools-environment-configuration
Sub-skill of devtools: Environment Configuration (+3).
devtools-docker-development-environment
Sub-skill of devtools: Docker Development Environment (+2).
devtools-containerization
Sub-skill of devtools: Containerization (+4).
devtools-1-reproducible-environments
Sub-skill of devtools: 1. Reproducible Environments (+4).
planning-code-goal-mcp-tools
Sub-skill of planning-code-goal: MCP Tools (+2).
memory-management-tools-systems
Sub-skill of memory-management: Tools & Systems.