LangChain

LangChain is an MIT-licensed framework for building AI agents with model integrations, tools and customizable agent loops

出典の原文 · EN

実際の例を見る

作者の例

Author diagram: model and agent harness

Author illustration of an agent harness: memory, skills, tools, context, subagents and system prompt surround the model. This is an architecture diagram from the documentation, rather than an application screenshot or tested output.

LangChain author diagram showing model surrounded by memory, skills, tools, context, subagents and system prompt
画像全体を見る
ライセンス

SVG decoded at declared1200×760 viewport; platform font rendering, no crop/upscale. Pixel equality is against that complete rendered RGBA, not a pre-existing publisher bitmap. Lossless WebP matches the full rendered RGBA.

MIT License

Copyright (c) 2025 LangChain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
作者の例

Source example: first model invocation

Complete Python block from the official README initializes the stated openai:gpt-5.5 model and invokes a greeting. Requires LangChain, the matching provider integration, credentials and model access; the exact source model string is retained, with no generated answer or independent availability test.

入力例

from langchain.chat_models import init_chat_model

model = init_chat_model("openai:gpt-5.5")
result = model.invoke("Hello, world!")
ライセンス

Complete original source file/block(s) unchanged. Outer README fence omitted for copying; grouped complete files keep their own language fences. Editorial title/prerequisites added. Nothing executed.

MIT License

Copyright (c) LangChain, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
作者の例

Source example: thread ID and typed context

Complete author Python file combines a fresh thread ID, typed user context and InMemorySaver. It uses the source Claude model and requires its provider integration/credentials. No weather tool is provided, so its weather question is not a live-weather integration. Helper assertions are unexecuted.

入力例

# :snippet-start: agent-invocation-thread-and-context-py
from dataclasses import dataclass

from langchain.agents import create_agent
from langchain_core.utils.uuid import uuid7
from langgraph.checkpoint.memory import InMemorySaver


@dataclass
class Context:
    user_id: str


agent = create_agent(
    model="claude-sonnet-4-6",
    tools=[],
    context_schema=Context,
    checkpointer=InMemorySaver(),
)

result = agent.invoke(
    {"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]},
    config={"configurable": {"thread_id": str(uuid7())}},
    context=Context(user_id="user-123"),
)
# :snippet-end:

# :remove-start:
if __name__ == "__main__":
    last = result["messages"][-1]
    text = last.content_blocks[0]["text"] if last.content_blocks else str(last.content)
    assert text.strip(), "expected non-empty assistant reply"
    print("✓ thread_id and context invoke together without error")
# :remove-end:
ライセンス

Complete original source file/block(s) unchanged. Outer README fence omitted for copying; grouped complete files keep their own language fences. Editorial title/prerequisites added. Nothing executed.

MIT License

Copyright (c) 2025 LangChain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
作者の例

Source example: read a profile from memory

Complete author Python file stores fictional John Smith data and exposes a context-selected lookup tool to an agent. Requires LangChain/LangGraph and the stated model provider credentials. InMemoryStore is a demo; use durable storage for production. No real profile lookup or model result was run.

入力例

# :snippet-start: long-term-memory-read-tool-inmemory-py
from dataclasses import dataclass

from langchain.agents import create_agent
from langchain.tools import ToolRuntime, tool
from langchain_core.runnables import Runnable
from langgraph.store.memory import InMemoryStore


@dataclass
class Context:
    user_id: str


# InMemoryStore saves data to an in-memory dictionary. Use a DB-backed store in production.
store = InMemoryStore()

# Write sample data to the store using the put method
store.put(
    (
        "users",
    ),  # Namespace to group related data together (users namespace for user data)
    "user_123",  # Key within the namespace (user ID as key)
    {
        "name": "John Smith",
        "language": "English",
    },  # Data to store for the given user
)


@tool
def get_user_info(runtime: ToolRuntime[Context]) -> str:
    """Look up user info."""
    # Access the store - same as that provided to `create_agent`
    assert runtime.store is not None
    user_id = runtime.context.user_id
    # Retrieve data from store - returns StoreValue object with value and metadata
    user_info = runtime.store.get(("users",), user_id)
    return str(user_info.value) if user_info else "Unknown user"


agent: Runnable = create_agent(
    model="claude-sonnet-4-6",
    tools=[get_user_info],
    # Pass store to agent - enables agent to access store when running tools
    store=store,
    context_schema=Context,
)

# Run the agent
agent.invoke(
    {"messages": [{"role": "user", "content": "look up user information"}]},
    context=Context(user_id="user_123"),
)
# :snippet-end:

# :remove-start:
if __name__ == "__main__":
    # Verify the store has the data
    result = store.get(("users",), "user_123")
    assert result is not None
    assert result.value["name"] == "John Smith"

    print("✓ Read tool with InMemoryStore works correctly")
# :remove-end:
ライセンス

Complete original source file/block(s) unchanged. Outer README fence omitted for copying; grouped complete files keep their own language fences. Editorial title/prerequisites added. Nothing executed.

MIT License

Copyright (c) 2025 LangChain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
出典に記載された機能

LangChainでできること

  1. 01Build agent loops with create_agent on LangGraph
  2. 02Connect model providers, tools and databases through integrations
  3. 03Customize context and human review through middleware
  4. 04Maintain workflow state with LangGraph checkpointing and persistence
出典の原文 · EN
違い

他と異なる点

Developers configure the agent loop, tools, application data and checkpoint storage for their use case. The framework is free to use under MIT; model access, hosting and optional LangSmith tracing, evaluation or deployment services need their own setup and may incur separate charges.

出典の原文 · EN
おすすめ

検討に向く人

  • Developers building tool-calling agents around their own application data
  • Engineering teams customizing model, context and human-review workflows
出典の原文 · EN
選ぶ前に

確認すること

  • 実際の作業を一つ試し、要件に合うか比較する。
  • 保存・共有・学習に利用されるデータを確認する。
  • 公式サイトで現在の料金、利用制限、解約条件を確認する。
サイト確認日

公式リンクは2026年10月25日に確認しました。機能の主張は独立して検証していません。

タスクに関連する項目

ツール料金利用方法用途
LangChain無料API業務フローを自動化
LangGraph未確認API業務フローを自動化
LangBot未確認Web, API業務フローを自動化
nanobot未確認Web, API, Windows, macOS, Linux実運用向けコードを生成 · 業務フローを自動化
Flowise未確認API業務フローを自動化