Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Strands Agents 入門 | Kiro と学ぶ Strands Agents 01

Strands Agents 入門 | Kiro と学ぶ Strands Agents 01

Strands Agents は、モデルが道具を選んで呼び、結果を見て次を決めるループを、自分のアプリの中で回すオープンソースの SDK です。この資料では、Kiro に MCP で Strands の最新の文書を引かせて「会議室の空きを探すエージェント」を書かせ、Amazon Bedrock の Claude Sonnet 5 を東京リージョンから global の推論プロファイルで呼んで動かし、metrics で道具の呼び出しとトークンを読み、FastAPI から呼ぶところまでを、本物の画面と実行結果で見せます。シリーズ「Kiro と学ぶ Strands Agents」の 01 (はじめる) です。

Avatar for Riku INADA

Riku INADA PRO

November 09, 2026

More Decks by Riku INADA

Other Decks in Technology

Transcript

  1. Kiro と学ぶ Strands Agents 01 はじめる Strands Agents ⼊⾨ Kiro

    に書かせて、 最初のエージェントを動かす 01 2026-11 時点 (Strands Agents 1.64、Kiro IDE 1.4) 2026 年 11 ⽉ 稲⽥ ⼤陸 アマゾン ウェブ サービス ジャパン © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Kiro + Strands Agents 1
  2. はじめに ⾃⼰紹介 稲⽥ ⼤陸 いなだ りく (いなりく) アマゾン ウェブ サービス

    ジャパン合同会社 ソリューションアーキテクト 製造業のお客様を中⼼に⽀援 最近の取り組み AI 駆動開発ライフサイクルの推進 Kiro と AWS Amplify の情報発信 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. X @inada_riku Speaker Deck speakerdeck.com/inariku Zenn zenn.dev/inariku GitHub github.com/inariku 2
  3. はじめに シリーズの中の位置 いまは 01 Strands Agents ⼊⾨、次は 02 道具を渡す、03 Strands

    harness はじめる 01–03 作り込む 01 Strands Agents ⼊⾨ 04–06 確かめて守る 07–08 本番へ 04 ループを操る 07 評価する 05 覚えさせる 08 安全に動かす 09 09 AgentCore に載せる 次に読む 02 道具を渡す 次に読む 03 Strands harness © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 06 複数のエージェント 3
  4. はじめに この資料で分かること Kiro に Strands Agents で書かせ、動かし、アプリから呼ぶまで 1 Strands Agents

    は、モデルが道具を選んで呼ぶループを、アプリの中で回す SDK 2 Kiro には Strands の今の⽂書を引かせてから、エージェントを書かせる 3 書けたエージェントを動かし、結果を読み、アプリの API から呼ぶ 前に読むとよい資料: ⽬指せ Kiro マスター 01 Kiro ⼊⾨ Kiro が書く agent.py © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. エージェント モデルと道具で回る 会議室 B と答える 4
  5. 1 Strands Agents とは エージェントのループ モデルが道具を選んで呼び、結果を⾒て、また考える。これを繰り返す ② モデルが考える 答えるか、道具を呼ぶか 道具を呼ばなく

    なったら答える ① 頼みと履歴 ③ 道具を呼ぶ これまでの会話と道具の結果 Strands が関数を動かす 1 周が 1 回の ④ 結果を履歴に⾜す ループ (cycle) 次の回のモデルが読む © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 5
  6. 1 Strands Agents とは モデルに任せる作り ⼿順を書かず、指⽰と道具を渡して、次の⼿はモデルが決める ⼿順をコードに書く作り モデルに任せる作り ① 部屋の⼀覧を読む

    指⽰ ② ⼈数で絞る ③ 予約と重なりを調べる ④ ⽂に整えて返す © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 次の⼿は 頼みの形が 変わると 書き⾜す 道具 モデルが決める 頼みが変わっても、道具と 指⽰の範囲なら書き⾜さない 6
  7. 1 Strands Agents とは エージェントの 3 つの部品 モデル、道具、指⽰の 3 つを渡すと、1

    つのエージェントになる モデル 考えて、道具を選ぶ 道具 + モデルが呼べる関数 指⽰ + 役割と決まり Amazon Bedrock の @tool の関数、 system_prompt に Claude Sonnet 5 など 組み込み、MCP 書く エージェント = Agent(...) © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 3 つを渡して 作る 7
  8. 1 Strands Agents とは Strands の名前の整理 1 から組む Harness SDK

    のほかに、組み⽴て済み、評価、囲いの部品がある Strands Agents (AWS が公開したオープンソースの SDK) Strands Harness SDK Strands harness Strands Evals Shell と Box strands-agents 組み⽴て済み 評価 囲い 1 から組む 既定の指⽰と道具 出す前に確かめる 安全に動かす 01、02、04〜06 03 07 08 載せる先の 1 つ: Amazon Bedrock AgentCore (AWS のサービス) → 09 ハーネス = モデルの周りの仕組み (ループ、道具、記憶、許可)。詳しくは 03 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 8
  9. 1 Strands Agents とは どのモデルでも 既定は Amazon Bedrock。替えるのはモデルの指定だけ Amazon Bedrock

    Anthropic OpenAI Agent Google Ollama 例題は東京リージョンから呼んだ global. で始まる ID は、処理するリージョンが東京に限らない (付録 A4) © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. LiteLLM ほか 紫が既定 9
  10. 2 準備 ⼿元の準備 Python と uv、AWS の資格情報、モデルを使える状態を⽤意する py Python 3.10

    以上 uv AWS の資格情報 モデルの利⽤ 例題は 3.13 で ⼊れて動かす Bedrock を呼べる 多くは最初の呼び出し 動かした uv run agent.py 権限とリージョン で使えるようになる (例題は東京) Anthropic は初回に 利⽤⽬的を出す 費⽤はトークン (⽂字のかたまり) の量で決まる (18 枚⽬)。細部と詰まったときは付録 A1、A2 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 10
  11. 2 準備 Kiro に Strands を教える Strands の⽂書を引く MCP サーバーを⾜し、今の

    API を確かめさせる Quickstart の Kiro ⽤の 設定 (ユーザー単位) を、例題の ワークスペースに置いた 7 ⾏⽬の autoApprove で、2 つの 道具を聞かずに使わせた .kiro/settings/mcp.json の 7 ⾏⽬ "autoApprove": ["search_docs", "fetch_doc"] © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 11
  12. 2 準備 例題 会議室の予約を⼿伝うエージェント。まず空いている部屋を探すだけを作る 会議室は 3 つ 明⽇の 10 時から

    6 ⼈で使える 部屋は? エージェント Claude Sonnet 5 list_rooms 部屋と定員 find_free_slots 空いている部屋 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. A4⼈ B8⼈ C 12 ⼈ data/ (⼿元の JSON) rooms bookings users 12
  13. 3 Kiro に書かせる Kiro への頼み⽅ 何を作るか、SDK とモデル、確かめ⽅、終わりの条件を書く 何を作るか SDK とモデル

    確かめ⽅ 終わりの条件 会議室の空きを探すエージェントを作って。 道具は list_rooms と find_free_slots の 2 つで、data/ の JSON を読む Strands Agents 1.64 の Python SDK で。モデルは Amazon Bedrock の Claude Sonnet 5 (global.anthropic.claude-sonnet-5) を東京リージョンで呼ぶ 書く前に strands-agents の MCP で今の API を確かめて。 最後に、道具の呼び出し、ループの回数、トークンの量を表⽰する uv run で動かして、明⽇ 10 時から 6 ⼈で使える部屋を答えたら終わり © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 13
  14. 3 Kiro に書かせる Kiro の 1 回の仕事 Kiro は、今の API

    を調べてから書き、動かして答えを確かめて終えた Kiro の 1 回の仕事 MCP で今の API を調べる 東京でモデルを呼べるか確かめる agent.py を書く uv run で動かし、答えを確かめる 約 11 分、3.55 クレジット Kiro の単位。Bedrock の費⽤は別 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 14
  15. 3 Kiro に書かせる できたコード: 道具 docstring と型を付けた関数に @tool を付けると、道具になる 1

    @tool を付けると、 モデルが呼べる道具になる 2 名前、docstring、型を モデルが読んで、 3 返した値 (部屋の⼀覧) が、 次に考える材料になる 呼ぶかを決める © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 15
  16. 3 Kiro に書かせる できたコード: Agent を作って呼ぶ モデルと道具を Agent に渡し、頼みの⽂を渡して呼ぶ model

    考えるモデル © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. tools 呼べる道具 agent(...) 頼むと、ループが回って答えが返る 16
  17. 4 動かして、アプリから呼ぶ 動かす uv run agent.py で動かすと、道具を 1 回呼んで会議室 B

    を答えた 1 周⽬ find_free_slots を 1 回呼ぶ 2026-11-10、10:00〜11:00、 6 ⼈以上 2 周⽬ 結果を読んで答える 会議室 B (定員 8 ⼈) 指定が無いので 1 時間と仮定した © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 17
  18. 4 動かして、アプリから呼ぶ 何が起きたかを⾒る 結果の metrics で、道具の呼び出し、ループの回数、トークンを読む 道具の呼び出し どの道具を何回呼び、失敗したか ループの回数 モデルを呼んだ周の数

    (今回 2) list_rooms は呼ばれなかった トークン ⼊⼒と出⼒の量。費⽤の元 定員は find_free_slots の引数で絞った (Kiro の報告)。 渡した道具を全部使うとは限らない © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. result.metrics から読める 18
  19. 4 動かして、アプリから呼ぶ アプリから呼ぶ エージェントは関数のように呼べる。API の処理の中で agent(...) を呼ぶ api.py は Kiro

    CLI 3.1.0 に 書かせた。POST /ask の中で agent(...) を呼ぶ。 ⽴て⽅は付録 A1。本番の置き場所は 09 POST /ask agent(...) api.py FastAPI の関数 エージェント 道具とモデル 答えを JSON で返す ⾃分のアプリ © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 19
  20. まとめ まとめ 3 つの部品とループ。Kiro には今の⽂書を引かせて書かせる 1 Strands Agents は、モデルが道具を選んで呼ぶループを、アプリの中で回す SDK

    2 Kiro には Strands の今の⽂書を引かせてから、エージェントを書かせる 3 書けたエージェントを動かし、結果を読み、アプリの API から呼ぶ Kiro が書く agent.py © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. エージェント モデルと道具で回る 会議室 B と答える 21
  21. まとめ 次に読む資料 予約の道具を⾜すなら 02、組み⽴て済みで始めるなら 03 02 03 ハーネス 01 道具を渡す

    Strands harness ハーネスエンジニアリング⼊⾨ 予約の道具と MCP を⾜す 組み⽴て済みで始める Kiro の周りの仕組みを作る このシリーズの次の回 既定の指⽰と道具が⼊っている 別のシリーズ (作成中) © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 22
  22. 付録 A1 準備の細部と、Kiro に任せた範囲 準備の細部 Kiro に任せた範囲 依存: pyproject.toml に

    strands-agents==1.64.* (Kiro が書いた)。 uv run が⼊れて動かす Kiro IDE は Supervised (Autopilot をオフ)。 コマンドは読んで Allow、書いたファイルは Accept で受け⼊れた 資格情報: aws configure などのプロフィールか 環境変数 (例題は SSO のプロフィール) 聞かずに使わせたのは search_docs と fetch_doc だけ 権限: bedrock:InvokeModel と InvokeModelWithResponseStream。初めてのモデルは Marketplace の権限と⽀払い⽅法も要る uv run は⾃分の資格情報で Bedrock を呼ぶ。 トークンの分の費⽤がかかる Anthropic: コンソールのモデルカタログで選ぶと、 利⽤⽬的のフォームが出る (1 回) ⼈が読むところ: docstring、system_prompt、 書く道具が無いこと uvx は uv に付いてくる。API は uv run uvicorn api:app -host 127.0.0.1 --port 8000 で⽴てた © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 23
  23. 付録 A2 詰まったとき 出たこと 直し⽅ AccessDeniedException Anthropic の利⽤⽬的のフォーム、IAM の 権限

    (bedrock:InvokeModel、Marketplace) を確かめる on-demand throughput isn't supported 推論プロファイルの ID (例題は global. で始まる ID) で呼ぶ The provided model identifier is invalid そのリージョンが、その推論プロファイルに対応しているかを 確かめる Unable to locate credentials aws configure などで資格情報を⽤意する (付録 A1) Kiro の MCP サーバーがつながらない uv (uvx) を⼊れる。Kiro の MCP の画⾯で接続を確かめる Kiro が古い書き⽅で書く 頼みに SDK の版を書き、MCP で今の API を確かめさせる 道具を呼ばない、違う道具を呼ぶ 道具の docstring と system_prompt を直す。モデルはそれを 読んで選ぶ © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 24
  24. 付録 A3 例題の指⽰とデータ rooms.json: 会議室 A (4 ⼈)、B (8 ⼈)、C

    (12 ⼈)。users.json: ID だけの 5 ⼈ (この回では使わない) bookings.json: 2026-11-10 は A 9:30〜10:30、C 10:00〜11:30、B 13:00〜14:00 など 5 件 (撮った⽇の明⽇に合わせた) 例題のコードは公開していない。Kiro が書くコードは、頼むたびに少し変わる © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 25
  25. 付録 A4 ⽤語 ⽤語 意味 ⽤語 意味 エージェント 道具を選んで呼ぶ AI

    トークン モデルが数える⽂字の単位 ループ 考えて道具を呼ぶ繰り返し metrics 1 回の頼みの記録 周 (cycle) モデルを 1 回呼ぶ単位 system_prompt エージェントへの指⽰の⽂ 道具 (tool) モデルが呼べる関数 MCP 外の道具とつなぐ決まり プロバイダー モデルを貸すサービス docstring 関数の説明の⽂ 推論プロファイル モデルを呼ぶ ID (global. など) リージョン AWS の場所 (例題は東京) Strands Harness SDK 1 から組む SDK uv、uvx Python の⼊れ物と実⾏の道具 Strands harness 組み⽴て済みのエージェント FastAPI Web の API を作る道具 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 26
  26. 付録 A5 出典と参考 strandsagents.com (2026-11-09 に読んだ) https://strandsagents.com/ Python Quickstart、Agent loop、Model

    providers、Amazon Bedrock、Create custom tools、Metrics、 Strands harness、Strands Evals quickstart、Box quickstart、Production Agent API with FastAPI Strands Agents のブログ「Introducing Strands Agents, an Open Source AI Agents SDK」(2025-05-16) https://strandsagents.com/blog/introducing-strands-agents/ GitHub strands-agents/harness-sdk https://github.com/strands-agents/harness-sdk Amazon Bedrock User Guide「Request access to models」 https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html kiro.dev のドキュメント (MCP configuration) https://kiro.dev/docs/ ⽬指せ Kiro マスター 01 Kiro ⼊⾨、07 MCP と Powers https://speakerdeck.com/inariku © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 27