「AIエージェントキャッチアップ #44 - Strands Agents」を開催しました

ジェネラティブエージェンツの大嶋です。

「AIエージェントキャッチアップ #44 - Strands Agents」という勉強会を開催しました。

generative-agents.connpass.com

アーカイブ動画はこちらです。

www.youtube.com

Strands Agents

今回は、AWS製のフレームワーク「Strands Agents」をキャッチアップしました。

Strands Agentsの公式Webサイトはこちらです。

strandsagents.com

GitHubリポジトリはこちらです。

github.com

今回のポイント

Strands Agentsとは

Strands Agentsは、AWSが公開したAIエージェントのフレームワークです。 2025年7月にバージョン1.0がリリースされています。

Strands Agentsを動かしてみる

Strands Agentsはpipで簡単にインストールできます。

pip install strands-agents

Strands Agentsを単純に動かすには、以下のようなコードを実行します。

from strands import Agent

agent = Agent()

agent("こんにちは")

すると、標準出力にストリーミングで応答が表示されます。

デフォルトでは、us-west-2リージョンのAmazon Bedrockにアクセスし、Claude 4 Sonnetを使用するとのことです。

Strands AgentsにおけるToolの基本

Strands Agentsには、AIエージェントのフレームワークとしての基本的な機能が一通りそろっています。

まず、Function callingを繰り返すシンプルなエージェントとしての機能が提供されており、以下のようにツールを設定して使用することができます。

agent = Agent(tools=tools)

ツールは後述するBuilt-inのものを使うこともできれば、自作することもできます。

ツールを自作する場合、@toolデコレータを使うのが簡単です。

from strands import Agent, tool

@tool
def get_weather(city: str) -> str:
    """Get the weather of a city"""
    return f"The weather of {city} is sunny."

agent = Agent(tools=[get_weather])

上記のように、Pythonの関数をツールとして設定する以外に、Pythonファイルのパスをツールとして指定することもできます。

agent = Agent(tools=["/path/to/my_tool.py"])

また、./tools/ディレクトリ以下のツールを自動で読み込む機能もあるようです。

strandsagents.com

Built-in Tools

Strands Agentsには様々な組み込みツールが用意されています。

calculater・current_time・python_replといった良く見かけるツールに加えて、mem0_memoryやa2a_clientといったツールも提供されています。

https://strandsagents.com/latest/documentation/docs/user-guide/concepts/tools/example-tools-package/strandsagents.com

セッション管理・Human-in-the-Loop

Strands Agentsでは、セッション管理の機能もあります。

strandsagents.com

Human-in-the-Loopについては、ターミナルであればhandoff_to_userというツールで実装できると書かれています。

https://strandsagents.com/latest/documentation/docs/user-guide/concepts/tools/example-tools-package/#human-in-the-loop-with-handoff_to_userstrandsagents.com

セッション管理の機能を応用すればWebアプリケーションでもHuman-in-the-Loopを実現できるのかもしれませんが、具体的な実装方法まではドキュメントでの記載が見当たらず、分かりませんでした。

マルチエージェント

Strands Agentsは、マルチエージェントの実装方式をいくつかサポートしています。

  • Agent2Agent (A2A)
  • Agents as Tools
  • Swarm
  • Graph
  • Workflow

Agents as Toolsは、Supervisor型とも呼ばれるマルチエージェントの定番の構成です。 また、Swarmもマルチエージェントの定番構成です。

Graph

Strands AgentsのGraph機能では、LangGraphのようなアプローチでAgentic Workflowを構築できます。

builder = GraphBuilder()

builder.add_node(researcher, "research")
builder.add_node(report_writer, "report")

builder.set_entry_point("research")
builder.add_edge("research", "report")

graph = builder.build()

add_edgeにはconditionも設定でき、conditionがTrueの場合のみ次のノードに処理が進むという分岐が実装できます。

ループにも対応しているかはドキュメントから読み取れませんでしたが、ループも可能であればかなり実用的だと思います。

strandsagents.com

Workflow Tool

Strands AgentsのWorkflow Tool機能は、AIエージェントのフレームワークでもあまり見かけないもので、少し見ただけでは理解しきれませんでした。

いくつかのタスクに依存関係を指定して適当な順番で処理させることができる、といった機能に見えましたが、詳細は改めて調べる必要がありそうです。

strandsagents.com

次回のご案内

以上、今回は「Strands Agents」をキャッチアップしました。

次回は「AIエージェントキャッチアップ #45 - Serena」ということで、コーディングエージェントツールキットの「Serena」がテーマです!

generative-agents.connpass.com

ご興味・お時間ある方はぜひご参加ください!

また、その次の回以降のテーマも募集しているので、気になるエージェントのOSSなどあれば教えてください!