원클릭으로
langchain-knowledge-patch
LangChain
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
LangChain
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
AlmaLinux
Angular
Arch Linux
Astro
Auth.js
AWS SDK
| name | langchain-knowledge-patch |
| description | LangChain |
| license | MIT |
| version | 1.1.0 |
| metadata | {"author":"Nevaberry"} |
Use this guide when choosing current LangChain, LangGraph, provider-integration, MCP-adapter, or Deep Agents APIs. Read the topic reference before changing an agent loop, middleware policy, graph state, streaming contract, or provider tool.
| Reference | Topics |
|---|---|
| Agents and tools | create_agent, middleware hooks and policies, structured output, model profiles, tool runtime injection, dynamic tools, custom state, and ToolNode errors |
| Anthropic integration | Native schemas, tool metadata and streaming, effort, citations, caching, context management, provider tools, code execution, remote MCP, and tool search |
| Deep Agents | Harness tools, filesystem and binary backends, protocol v2, background subagents, sandboxes, profiles, context storage, summarization, memory, and CLI use |
| LangGraph workflows | Typed stream and invoke results, event projections, delta checkpoints, timeouts and recovery, draining, JavaScript state schemas, node caching, fan-in, and reconnectable streams |
| MCP adapters | Session lifetime, structured and multimodal results, resources, prompts, runtime-aware interceptors, callbacks, progress, logging, and elicitation |
| OpenAI integration | Official and Azure endpoints, custom and built-in tools, Responses routing and continuation, approvals, compaction, reasoning, PDF input, and prompt caching |
| v1 migration | Package split, runtime floor, classic imports, agent migration, provider-neutral content blocks, rollout limits, and Google GenAI v4 |
The main Python and JavaScript packages now focus on core agent abstractions. Install the classic package only where migration cannot happen immediately:
uv pip install --upgrade langchain langgraph
uv pip install langchain-classic
npm install langchain @langchain/core @langchain/langgraph
npm install @langchain/classic
langchain-classic.@langchain/classic; for example, replace langchain/chains with
@langchain/classic/chains.langgraph.prebuilt.create_react_agent with
langchain.agents.create_agent.Custom agent state must extend AgentState as a TypedDict. Pydantic models and
dataclasses are not accepted for this purpose. Put a schema on the middleware
that owns the fields; reserve create_agent(state_schema=...) for compatibility
with tool-only state.
from langchain.agents import AgentState
from langchain.agents.middleware import AgentMiddleware
class PreferencesState(AgentState):
user_preferences: dict
class PreferencesMiddleware(AgentMiddleware):
state_schema = PreferencesState
StateBackend() and StoreBackend() directly; runtime factories
such as lambda rt: StateBackend(rt) are deprecated.BackendProtocolV2 structured results and report
failures in error. Use readRaw() for binary bytes and rename
lsInfo/grepRaw/globInfo to ls/grep/glob.adaptBackendProtocol while migrating a v1 backend.langchain-google-genai v4 uses Google's consolidated SDK for both Gemini API
and Vertex AI. Expect small upgrade changes and migrate away from the
corresponding deprecated langchain-google-vertexai packages.
create_agentcreate_agent builds a LangGraph-backed model/tool loop. It accepts provider
model strings, tools, a system prompt, middleware, state, and structured output.
from langchain.agents import create_agent
agent = create_agent(
model="openai:gpt-5",
tools=[get_weather],
system_prompt="Fetch weather when needed and answer concisely.",
name="weather_assistant",
)
Names become node identifiers when agents are embedded as subgraphs. Restrict them to letters, digits, underscores, and hyphens.
Python middleware subclasses AgentMiddleware; JavaScript uses
createMiddleware. The lifecycle consists of these hook pairs:
| Python | JavaScript |
|---|---|
before_agent | beforeAgent |
before_model | beforeModel |
wrap_model_call | wrapModelCall |
wrap_tool_call | wrapToolCall |
after_model | afterModel |
after_agent | afterAgent |
Use bundled middleware for common policies:
PIIMiddleware supports named or regex detectors and redact or block.SummarizationMiddleware supports token triggers and profile-aware behavior.HumanInTheLoopMiddleware configures per-tool approve, edit, and reject.JavaScript dynamicSystemPromptMiddleware results are additive: returned strings
and SystemMessage objects extend existing system messages rather than replacing
them.
Structured output runs inside the agent loop. Use ToolStrategy when the model
should emit a schema through tool calling; use ProviderStrategy for native
schema generation. A model profile can infer native support.
from langchain.agents import create_agent
from langchain.agents.structured_output import ToolStrategy
from pydantic import BaseModel
class WeatherReport(BaseModel):
temperature: float
condition: str
agent = create_agent(
model="openai:gpt-4o-mini",
tools=[weather_tool],
response_format=ToolStrategy(WeatherReport, handle_errors=True),
)
Python handle_errors and JavaScript handleErrors control schema-parse and
multiple-output failures. Provider strategies can request strict schema
adherence explicitly. If middleware switches models, replacement models must not
already be bound with bind_tools when structured output is enabled.
Declare runtime: ToolRuntime on a tool to receive model-hidden state, immutable
typed context, store, stream writer, config, and tool-call ID. The argument names
runtime and config are reserved. Return Command to update state, and include
a correlated ToolMessage when the model needs the result.
from langchain.messages import ToolMessage
from langchain.tools import ToolRuntime, tool
from langgraph.types import Command
@tool
def set_language(language: str, runtime: ToolRuntime) -> Command:
return Command(update={
"preferred_language": language,
"messages": [ToolMessage(
content=f"Language set to {language}.",
tool_call_id=runtime.tool_call_id,
)],
})
Fields written by parallel tools need reducers. A tool discovered at runtime
must be added in both wrap_model_call and wrap_tool_call; advertising it to
the model does not install an executable implementation.
message.content_blocks to normalize text, reasoning, citations, tool
calls, server-side tool calls, and multimodal content across integrations.stream_mode="messages" to receive token chunks from ordinary
model.invoke() calls inside graph nodes; select calls with metadata such as
langgraph_node or model tags.version="v2", stream methods emit StreamPart, while invoke
methods return GraphOutput.value and GraphOutput.interrupts.version="v3", consume typed run and model-call
projections instead of reconstructing events from provider-specific payloads.ToolNode catches invocation errors by default but re-raises failures raised by
tool execution. Set handle_tool_errors to True, a model-visible string, an
exception handler, or a tuple of exception types when execution failures should
return to the model.
from langgraph.prebuilt import ToolNode
node = ToolNode(tools, handle_tool_errors=(ValueError, TypeError))
Provider-native tools, response continuation, caching, context compaction, and approval loops have integration-specific contracts. Do not infer one provider's wire shape from another. Read the provider reference before binding server-side tools or retaining provider content blocks in message history.
For MCP tools, decide whether each invocation may use a fresh session. Open an explicit session for server-side state, and use runtime-aware interceptors for tenant headers, policy checks, state updates, or rerouting.
For Deep Agents, choose filesystem mutation policy, backend protocol, sandbox, subagent behavior, and persistence explicitly. Background subagents require a LangSmith Deployment.