Files
Magnus Hedemark fe3be63800 feat: add langchain — expert LangChain framework skill
Greenfield SkillOpt: 3 epochs optimizing discoverability, decision
guidance, and troubleshooting for a brand-new LangChain skill.

Epoch 1 — Prominence:
- Added critical AgentExecutor deprecation callout at top
- Framework Routing Guide for cross-portfolio decisions

Epoch 2 — Decision Guidance:
- Where to Start table with AgentExecutor migration row
- Pipeline Mode table (Quick/RAG/Agent/Production)

Epoch 3 — Pattern Expansion:
- Troubleshooting table with reference file links
- FAQ section covering installation, migration, performance

13 files: SKILL.md, 7 references, 4 templates, 1 script.
v1.0.0 -> v1.0.3 across 3 SkillOpt epochs.

Signed-off-by: Magnus Hedemark <magnus919@pm.me>
2026-07-09 14:13:34 -04:00

28 lines
789 B
Python

#!/usr/bin/env python3
"""Agent with tool-calling using create_agent (v1.0+)."""
from langchain_openai import ChatOpenAI
from langchain.agents import create_agent
from langchain_core.tools import tool
from langgraph.checkpoint.memory import MemorySaver
@tool
def search_web(query: str) -> str:
"""Search the web for information."""
return f"Simulated results for: {query}"
model = ChatOpenAI(model="gpt-4o")
tools = [search_web]
agent = create_agent(
model, tools,
prompt="You are a research assistant. Use the search tool to answer questions."
)
# With persistence
config = {"configurable": {"thread_id": "session-1"}}
result = agent.invoke(
{"messages": [("user", "Search for LangChain v1.0 features")]},
config=config
)
print(result["messages"][-1].content)