0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

LangChainエージェント入門 — AIが自律的にツールを選ぶ仕組み

0
Last updated at Posted at 2026-08-28

はじめに

LangChainでRAG(検索拡張生成)を実装すると、AIは与えられた文書を参照して回答を作れます。しかし、RAGだけでは「今日の天気」も「正確な数値計算」もできません。AIが言葉を返すだけでなく、行動を取るにはどうすればよいでしょうか。

その答えが**ツール(Tool)エージェント(Agent)**です。本記事では、LangChain 0.3系でAIに道具を持たせ、自律的に判断させる仕組みを整理します。

ツールとは - AIに「行動」を取らせる接口

ツールは、AIと外部の世界をつなぐ接口です。ツールを与えると、AIは次のような行動を取れるようになります。

  • 計算 - LLMは算術が苦手なので、計算機に任せる
  • 情報取得 - 天気APIやニュースAPIにアクセスする
  • データベース照会 - 社内DBからレコードを取得する
  • ファイル操作 / API呼び出し - 外部サービスを操作する

AIは自分で直接コードを実行するわけではありません。AIは「どのツールを、どんな引数で使うか」を判断し、その判断に基づいてLangChainが実際の関数を呼び出します。この仕組みを**関数呼び出し(Function Calling)**と呼びます。AIは司令塔であり、実際の作業はLangChainが代行します。

ツール定義の基本形 - @tool デコレータ

LangChainでツールを定義する最も簡単な方法は、 デコレータを使うことです。通常のPython関数にデコレータを付けるだけで、AIが理解できるツールになります。

これだけで定義完了です。重要なポイントが三つあります。

1. 型ヒントを必ず付ける

引数と戻り値に型ヒント( や )を付けます。LangChainはこの型情報を読み取り、AIに「このツールは文字列を受け取って整数を返す」と教えます。型ヒントがないと、AIが引数の渡し方を判断できません。

2. docstring を必ず書く

関数の直下にある三重引用符のコメント(docstring)は、AIにとってのツールの説明書です。AIはこの文章を読んで「何に使うべきか」を判断します。docstringが不十分だと、AIがツールの存在に気づかず、使わないまま終わってしまいます。人間の開発者ではなく、AIに向けて書くのがポイントです。

3. デコレータを付ける

を付けることで、普通の関数がLangChainのツールオブジェクトに変換されます。型情報とdocstringが自動的に抽出され、AIが理解できる形式になります。

実践的なツールの例

天気情報を取得するツールを作ってみましょう。ここでは動作確認しやすいようモックで実装します。

ツールの中身は普通のPython関数です。API呼び出し、ファイル読み込み、計算処理など、Pythonでできることは何でも組み込めます。AIは関数の中身を知る必要がありません。docstringと引数の型情報だけを見て、いつこのツールを使うべきかを判断します。

複数引数と選択肢の制約

複数の引数を取るツールも定義できます。引数に 型を使うと、「この値のいずれか」をAIに強制できます。

で選択肢を明示できるため、AIが誤った値を渡すのを防げます。

ツールをAIに使わせる

ツールを定義したら、 メソッドでLLMに紐づけます。

には、AIがツールを使うと判断した場合、そのツール名と引数が入ります。

しかし、これだけではAIは一度ツールを呼び出したら終わりです。ツールの結果を見てさらに別のツールを使ったり、最終回答を組み立てたりするには、エージェントが必要です。

エージェントとは - 自律的に判断を繰り返すAI

エージェントとは、LLMを「思考エンジン」として使い、自律的にツールを選び、行動し、結果を観察し、次の行動を決めるAIシステムです。従来のチェーンが「固定された手順を上から下へ進む」のに対し、エージェントは「状況に応じて次の手を自分で決める」ことができます。

チェーン(固定手順)

  1. プロンプトを作る -> 2. LLMに渡す -> 3. 結果を受け取る

エージェント(自律判断)

  1. ユーザーの質問を受け取る
  2. LLMが「何をすべきか」を考える
  3. 必要なツールを選んで呼び出す
  4. ツールの結果を観察する
  5. 「まだ情報が足りないか」「もう回答できるか」を判断
  6. 必要なら別のツールを呼ぶ(3に戻る)
  7. 十分な情報が集まったら最終回答を出す

この「考えて、行動して、観察して、また考える」という織り返しがエージェントの本質です。

ReAct - 推論と行動のサイクル

エージェントの思考方式として最も広く使われているのが**ReAct(Reasoning and Acting)**です。推論と行動を交互に織り返し、複雑な課題を段階的に解決します。

ReActのサイクルは次の四つのステップから成ります。

  1. Thought(思考) - 課題を分析し、次に何をすべきかを考える
  2. Action(行動) - 思考に基づいてツールを選び、呼び出す
  3. Observation(観察) - ツールの結果を受け取り、内容を読む
  4. Loop(反復) - 観察結果をもとに再び思考に戻る。十分な情報が集まれば最終回答を出す

例えば「東京の天気を調べて、傘が必要か判断して」という依頼に対し、ReActエージェントは次のように動きます。

  1. Thought - 「天気を知るには天気ツールが必要だ」
  2. Action - を呼び出す
  3. Observation - 「晴れ、気温28度」を受け取る
  4. Thought - 「晴れなので傘は不要だ」
  5. 最終回答 - 「東京は晴れで気温28度です。傘は不要でしょう」

ReActは一度のやり取りで終わらず、必要なだけ思考と行動を織り返します。

LangChain 0.3でReActエージェントを構築する

LangChain 0.3系では、 パッケージの 関数でReActエージェントを簡単に構築できます。

Collecting langgraph
Downloading langgraph-1.2.11-py3-none-any.whl.metadata (4.9 kB)
Collecting langchain-openai
Downloading langchain_openai-1.6.0-py3-none-any.whl.metadata (3.4 kB)
Collecting langchain-core<2,>=1.4.7 (from langgraph)
Downloading langchain_core-1.6.1-py3-none-any.whl.metadata (4.8 kB)
Collecting langgraph-checkpoint<5.0.0,>=4.1.0 (from langgraph)
Downloading langgraph_checkpoint-4.2.0-py3-none-any.whl.metadata (6.7 kB)
Collecting langgraph-prebuilt<1.2.0,>=1.1.0 (from langgraph)
Downloading langgraph_prebuilt-1.1.0-py3-none-any.whl.metadata (5.2 kB)
Collecting langgraph-sdk<0.5.0,>=0.4.2 (from langgraph)
Downloading langgraph_sdk-0.4.4-py3-none-any.whl.metadata (5.1 kB)
Requirement already satisfied: pydantic>=2.7.4 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from langgraph) (2.12.5)
Collecting xxhash>=3.5.0 (from langgraph)
Downloading xxhash-4.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (17 kB)
Requirement already satisfied: certifi>=2024.6.2 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from langchain-openai) (2026.2.25)
Collecting openai<4.0.0,>=2.45.0 (from langchain-openai)
Downloading openai-3.5.0-py3-none-any.whl.metadata (41 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.7/41.7 kB 2.3 MB/s eta 0:00:00
Collecting tiktoken<1.0.0,>=0.7.0 (from langchain-openai)
Using cached tiktoken-0.14.0-cp311-cp311-manylinux_2_28_x86_64.whl.metadata (6.7 kB)
Requirement already satisfied: httpx<1.0.0,>=0.23.0 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from langchain-core<2,>=1.4.7->langgraph) (0.28.1)
Collecting jsonpatch<2.0.0,>=1.33.0 (from langchain-core<2,>=1.4.7->langgraph)
Downloading jsonpatch-1.33-py2.py3-none-any.whl.metadata (3.0 kB)
Collecting langchain-protocol>=0.0.17 (from langchain-core<2,>=1.4.7->langgraph)
Downloading langchain_protocol-0.0.19-py3-none-any.whl.metadata (2.4 kB)
Collecting langsmith<1.0.0,>=0.3.45 (from langchain-core<2,>=1.4.7->langgraph)
Downloading langsmith-0.11.2-py3-none-any.whl.metadata (22 kB)
Requirement already satisfied: packaging>=23.2.0 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from langchain-core<2,>=1.4.7->langgraph) (26.0)
Requirement already satisfied: pyyaml<7.0.0,>=5.3.0 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from langchain-core<2,>=1.4.7->langgraph) (6.0.3)
Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.1.0 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from langchain-core<2,>=1.4.7->langgraph) (9.1.4)
Requirement already satisfied: typing-extensions<5.0.0,>=4.7.0 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from langchain-core<2,>=1.4.7->langgraph) (4.15.0)
Collecting uuid-utils<1.0,>=0.12.0 (from langchain-core<2,>=1.4.7->langgraph)
Downloading uuid_utils-0.17.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.4 kB)
Collecting ormsgpack>=1.12.0 (from langgraph-checkpoint<5.0.0,>=4.1.0->langgraph)
Downloading ormsgpack-1.12.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.2 kB)
Collecting orjson>=3.11.5 (from langgraph-sdk<0.5.0,>=0.4.2->langgraph)
Downloading orjson-3.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (41 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.0/42.0 kB 3.6 MB/s eta 0:00:00
Requirement already satisfied: websockets<17,>=14 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from langgraph-sdk<0.5.0,>=0.4.2->langgraph) (15.0.1)
Requirement already satisfied: anyio<5,>=4.10.0 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from openai<4.0.0,>=2.45.0->langchain-openai) (4.12.1)
Collecting httpx2<3,>=2.7.0 (from openai<4.0.0,>=2.45.0->langchain-openai)
Downloading httpx2-2.12.0-py3-none-any.whl.metadata (9.5 kB)
Collecting jiter<1,>=0.16.0 (from openai<4.0.0,>=2.45.0->langchain-openai)
Downloading jiter-0.16.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.2 kB)
Requirement already satisfied: sniffio in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from openai<4.0.0,>=2.45.0->langchain-openai) (1.3.1)
Requirement already satisfied: annotated-types>=0.6.0 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from pydantic>=2.7.4->langgraph) (0.7.0)
Requirement already satisfied: pydantic-core==2.41.5 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from pydantic>=2.7.4->langgraph) (2.41.5)
Requirement already satisfied: typing-inspection>=0.4.2 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from pydantic>=2.7.4->langgraph) (0.4.2)
Requirement already satisfied: regex in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from tiktoken<1.0.0,>=0.7.0->langchain-openai) (2026.7.19)
Requirement already satisfied: requests in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from tiktoken<1.0.0,>=0.7.0->langchain-openai) (2.33.0)
Requirement already satisfied: idna>=2.8 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from anyio<5,>=4.10.0->openai<4.0.0,>=2.45.0->langchain-openai) (3.11)
Requirement already satisfied: httpcore==1.* in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from httpx<1.0.0,>=0.23.0->langchain-core<2,>=1.4.7->langgraph) (1.0.9)
Requirement already satisfied: h11>=0.16 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from httpcore==1.*->httpx<1.0.0,>=0.23.0->langchain-core<2,>=1.4.7->langgraph) (0.16.0)
Collecting httpcore2==2.12.0 (from httpx2<3,>=2.7.0->openai<4.0.0,>=2.45.0->langchain-openai)
Downloading httpcore2-2.12.0-py3-none-any.whl.metadata (25 kB)
Collecting idna>=2.8 (from anyio<5,>=4.10.0->openai<4.0.0,>=2.45.0->langchain-openai)
Downloading idna-3.19-py3-none-any.whl.metadata (9.2 kB)
Collecting truststore>=0.10 (from httpx2<3,>=2.7.0->openai<4.0.0,>=2.45.0->langchain-openai)
Downloading truststore-0.10.4-py3-none-any.whl.metadata (4.4 kB)
Collecting jsonpointer>=1.9 (from jsonpatch<2.0.0,>=1.33.0->langchain-core<2,>=1.4.7->langgraph)
Downloading jsonpointer-3.1.1-py3-none-any.whl.metadata (2.4 kB)
Requirement already satisfied: distro>=1.7.0 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from langsmith<1.0.0,>=0.3.45->langchain-core<2,>=1.4.7->langgraph) (1.9.0)
Collecting requests-toolbelt>=1.0.0 (from langsmith<1.0.0,>=0.3.45->langchain-core<2,>=1.4.7->langgraph)
Using cached requests_toolbelt-1.0.0-py2.py3-none-any.whl.metadata (14 kB)
Collecting zstandard>=0.23.0 (from langsmith<1.0.0,>=0.3.45->langchain-core<2,>=1.4.7->langgraph)
Downloading zstandard-0.25.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (3.3 kB)
Requirement already satisfied: charset_normalizer<4,>=2 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from requests->tiktoken<1.0.0,>=0.7.0->langchain-openai) (3.4.4)
Requirement already satisfied: urllib3<3,>=1.26 in ./.hermes/hermes-agent/venv/lib/python3.11/site-packages (from requests->tiktoken<1.0.0,>=0.7.0->langchain-openai) (2.6.3)
Downloading langgraph-1.2.11-py3-none-any.whl (248 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 248.9/248.9 kB 9.1 MB/s eta 0:00:00
Downloading langchain_openai-1.6.0-py3-none-any.whl (125 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 125.1/125.1 kB 7.0 MB/s eta 0:00:00
Downloading langchain_core-1.6.1-py3-none-any.whl (571 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 571.5/571.5 kB 11.4 MB/s eta 0:00:00
Downloading langgraph_checkpoint-4.2.0-py3-none-any.whl (56 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.8/56.8 kB 4.2 MB/s eta 0:00:00
Downloading langgraph_prebuilt-1.1.0-py3-none-any.whl (41 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.0/41.0 kB 2.4 MB/s eta 0:00:00
Downloading langgraph_sdk-0.4.4-py3-none-any.whl (162 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 162.3/162.3 kB 8.0 MB/s eta 0:00:00
Downloading openai-3.5.0-py3-none-any.whl (1.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 17.1 MB/s eta 0:00:00
Using cached tiktoken-0.14.0-cp311-cp311-manylinux_2_28_x86_64.whl (1.2 MB)
Downloading xxhash-4.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (261 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 261.0/261.0 kB 11.8 MB/s eta 0:00:00
Downloading httpx2-2.12.0-py3-none-any.whl (95 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 95.4/95.4 kB 7.0 MB/s eta 0:00:00
Downloading httpcore2-2.12.0-py3-none-any.whl (83 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.1/83.1 kB 6.5 MB/s eta 0:00:00
Downloading jiter-0.16.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (347 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 347.1/347.1 kB 14.9 MB/s eta 0:00:00
Downloading jsonpatch-1.33-py2.py3-none-any.whl (12 kB)
Downloading langchain_protocol-0.0.19-py3-none-any.whl (7.3 kB)
Downloading langsmith-0.11.2-py3-none-any.whl (753 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 753.9/753.9 kB 15.8 MB/s eta 0:00:00
Downloading orjson-3.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (131 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 131.3/131.3 kB 7.2 MB/s eta 0:00:00
Downloading ormsgpack-1.12.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (212 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 212.4/212.4 kB 9.4 MB/s eta 0:00:00
Downloading uuid_utils-0.17.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (324 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 324.3/324.3 kB 11.8 MB/s eta 0:00:00
Downloading idna-3.19-py3-none-any.whl (68 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 68.5/68.5 kB 5.0 MB/s eta 0:00:00
Downloading jsonpointer-3.1.1-py3-none-any.whl (7.7 kB)
Using cached requests_toolbelt-1.0.0-py2.py3-none-any.whl (54 kB)
Downloading truststore-0.10.4-py3-none-any.whl (18 kB)
Downloading zstandard-0.25.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (5.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.6/5.6 MB 27.1 MB/s eta 0:00:00
Installing collected packages: zstandard, xxhash, uuid-utils, truststore, ormsgpack, orjson, langchain-protocol, jsonpointer, jiter, idna, jsonpatch, httpcore2, tiktoken, requests-toolbelt, httpx2, openai, langsmith, langchain-core, langgraph-sdk, langgraph-checkpoint, langchain-openai, langgraph-prebuilt, langgraph
Attempting uninstall: jiter
Found existing installation: jiter 0.13.0
Uninstalling jiter-0.13.0:
Successfully uninstalled jiter-0.13.0
Attempting uninstall: idna
Found existing installation: idna 3.11
Uninstalling idna-3.11:
Successfully uninstalled idna-3.11
Attempting uninstall: openai
Found existing installation: openai 2.24.0
Uninstalling openai-2.24.0:
Successfully uninstalled openai-2.24.0
Successfully installed httpcore2-2.12.0 httpx2-2.12.0 idna-3.19 jiter-0.16.0 jsonpatch-1.33 jsonpointer-3.1.1 langchain-core-1.6.1 langchain-openai-1.6.0 langchain-protocol-0.0.19 langgraph-1.2.11 langgraph-checkpoint-4.2.0 langgraph-prebuilt-1.1.0 langgraph-sdk-0.4.4 langsmith-0.11.2 openai-3.5.0 orjson-3.12.0 ormsgpack-1.12.2 requests-toolbelt-1.0.0 tiktoken-0.14.0 truststore-0.10.4 uuid-utils-0.17.0 xxhash-4.0.1 zstandard-0.25.0

これだけでエージェントが完成します。 は、LLMがツールを呼ぶべきと判断したらツールを実行し、その結果を再度LLMに渡すという循環を内部のグラフ構造で構築します。

エージェントを動かす

メソッドに を含む辞書を渡すと、エージェントがReActサイクルを回し、最終的な回答を返します。

には、ユーザーの質問からツールの呼び出し、ツールの結果、最終回答まで、すべてのやり取りが順番に格納されています。最後のメッセージがAIの最終回答です。

複数ツールの連鎖を観察する

エージェントの真価は、複数のツールを順次使い分ける場面で発揮されます。

この質問に対して、エージェントは次のように動きます。

  1. 思考 - 「東京と福岡の気温を知る必要がある」
  2. 行動 - -> 「晴れ、気温28度」
  3. 行動 - -> 「雨、気温24度」
  4. 行動 - -> 「結果: 4.0」
  5. 最終回答 - 「東京と福岡の気温の差は4度です」

人間が手順を書かなくても、必要なツールを必要な順番で呼び出し、結果を組み合わせて回答を組み立てました。

システムプロンプトでエージェントの人格を決める

の 引数に文字列を渡すと、エージェント全体の振る舞いを制御できます。

同じツールを使っても、システムプロンプトで回答のスタイルや内容をがらりと変えられます。業務に組み込む際は、役割、回答のトーン、使ってよいツールの区分などを書いておくと、エージェントの暴走を防げます。

反復回数の上限を設定する

エージェントは自律的にツールを呼び出し続けますが、堂々めぐるに陷るおそれがあります。APIコストの観点からも、反復回数の上限を設けるのが安全です。

はグラフのノード遷移回数の上限です。上限に達すると が投げられるので、 〜 で受け止めます。本番環境では必ず上限を設定しましょう。

エージェント設計の注意点

エージェントは強力な反面、設計を間違えると予期しない動きをします。

  • docstringをAIに向けて書く - 曖昧な説明だとAIがツールを選び間違える。「何に使い、どんな引数を渡すか」を明確に書く
  • ツールを持ちすぎない - 一つのエージェントにつき5〜10個程度に押え、役割が明確に分かれるように整理する。多すぎる場合はエージェントを分ける(マルチエージェント構成)
  • 反復上限を必ず設定する - 止まらなくなるのを防ぐ
  • 回答の正確性を確認する - ツールの結果とAIの解釈が食い違う場合がある。重要な用途では人間が確認する工程を挿む

まとめ

本記事では、LangChainでAIに行動させるための仕組みを整理しました。

  • ツールはAIに「行動」を取らせる道具で、 デコレータで定義する
  • 型ヒントとdocstringが必須で、これらがAIにツールの使い方を伝える手がかりになる
  • でLLMにツールを紐づけ、AIにツール利用を判断させる
  • エージェントは、AIが自分で次の手を決める自律型システム
  • ReActは「思考->行動->観察->反復」のサイクルで複雑な課題を段階的に解決する
  • でReActエージェントを簡単に構築できる
  • システムプロンプトで役割を制御し、 で安全網を設ける

ツールとエージェントを組み合わせれば、AIは「言葉を返すだけ」から「道具を使って課題を解決する」へと変わります。まずは2〜3個のシンプルなツールで小さなエージェントを動かし、思考の過程を観察してみてください。


著者: 葉山悠希

本記事はLangChainによるAIエージェント構築の入門内容をQiita単体で完結するよう再構成したものです。より詳しい実装パターンや多ツール連携の事例については、参考書籍『LangChain x AI実践入門』も参照してください(Amazon: https://www.amazon.co.jp/dp/B0DTGRFN1F )。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?