Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Bedrock AgentをサポートしたPowertools for AWS Lambdaによ...
Search
fujioka-a
June 25, 2025
Technology
470
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Bedrock AgentをサポートしたPowertools for AWS Lambdaによる開発の効率化・省力化
Media-JAWS x JAWS-UG千葉支部 #2 幕張よ我々は帰ってきた!で発表した資料です(一部編集してます)
fujioka-a
June 25, 2025
More Decks by fujioka-a
See All by fujioka-a
エージェントはローカル、検証はMicroVM — Lambda MicroVMsでつくるServerless CI
fujioka6789
4
920
DevOps Agentで運用判断をチーム資産にする~Agent InstructionsとAgent Skillを継続的に育てる~
fujioka6789
0
310
【re:Invent2025 Notion reCap】AIエージェントを制御する “Agent SOP(Standard Operating Procedures)”をチームで継続的に管理・更新する
fujioka6789
0
57
re:Invent2025 大阪reCap “Agent SOP(Standard Operating Procedures)”で手軽に管理・更新できるAIエージェントを構築しよう
fujioka6789
0
120
re:Invent初参加でも120%満喫するための心構え@フォージビジョンre:Invent報告会
fujioka6789
0
300
書籍推薦AIエージェントを作ってみよう ワークショップ
fujioka6789
0
32
Other Decks in Technology
See All in Technology
2026-10-01_MagicPod_QAハーネスエンジニアリングとQA組織の未来像
ynisqa1988
1
460
AIアプリを使い分けるための共通ツール基盤を考えてみる#devio2026
osawa
0
130
【Findyテック文化祭ワークショップ】新卒エンジニア&採用担当と作る、 なりたい姿と今やるべき一歩
dip_tech
PRO
0
150
[2026 Oracle Technical Deep Dive] オンプレミスDBのCloud移行アプローチ:移行計画に基づくメソッドとツールの選択 (2026年9月17日開催)
oracle4engineer
PRO
0
110
HacobuにおけるFDEとは/登壇資料(戸井田 裕貴)
hacobu
PRO
1
720
全社共通データ基盤をつくる。ソニーのDatabricks活用とデータガバナンス設計の裏側
sony
0
300
覗いてみよう 関数型ビジュアル言語×2Dグラフィックスの世界
yohyamasaki
0
170
Execution in the Kingdom of Agents: Reflections on Abstraction and Complexity
bcantrill
0
770
行動するAIのためのオントロジー | DevRev — Encraft #26.pdf
dvrv_tknrszk
2
680
Claude起点の仕様駆動開発
tanakaseiya
0
310
いちAWSエンジニアのAI活用を振り返る #devio2026 / devio osaka 2026 kawahara
masahirokawahara
2
330
AgentCoreで実践するハーネスエンジニアリング
yakumo
1
250
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
How STYLIGHT went responsive
nonsquared
100
6.3k
Paper Plane (Part 1)
katiecoart
PRO
2
11k
The agentic SEO stack - context over prompts
schlessera
0
950
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
420
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
290
Marketing to machines
jonoalderson
1
5.8k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
760
Transcript
MEDIA-JAWS X JAWS-UG千葉支部#2 幕張よ我々は帰ってきた! 2025.6.25(火) Bedrock Agentをサポートした Powertools for AWS
Lambdaによる 開発の効率化・省力化
自己紹介 藤岡 敦史 前職:バックエンドエンジニア、 農業系や建設系のクライアントにて開発 現職:フォージビジョン所属、 インフラエンジニア、 フルスタックに多数のクライアントにて開発・構築 2025 All
AWS Certifications Engineer →ゴールドジャケット受け取れました!! 好きなAWSサービス Lambda
はじめに そもそも”Powertools”とは… ※もっと詳しく知りたい方は、ぜひ以下のAWS福井さんの資料を参照ください(個人的に神資料です) https://pages.awscloud.com/rs/112-TZM- 766/images/20221124_24th_ISV_DiveDeepSeminar_Lambda_Powertools.pdf Powertools • OSSライブラリ • ロギング、トレース、メトリクスなど、
ベストプラクティスの型・実装パターンがある程度 決まっている機能を手軽に導入できる →ボイラープレートを減らすことで、 開発速度やメンテナンス性を向上させられる • 以下の言語をサポート • Python • Java • TypeScript • .NET
従来のCore utilities • 以降の説明は、今回検証に使用したTypeScriptを前提に説明します • 以下がPowertoolsの主要機能(ユーティリティ)です ※言語によってユーティリティの充実度はマチマチです ユーティリティ 概要 トレース
X-rayと連携した処理のトレース ログ 構造化ロギング メトリクス カスタム名前空間を利用したメトリクス集計 Event Handler AppSync AppSync Eventからのパブリッシュ&サブスクライブ に対するイベントハンドリング ※他にも沢山ユーティリティはあるので、公式サイトを確認ください https://docs.powertools.aws.dev/lambda/typescript/latest/
最新のCore utilities • 今回新たに、Bedrock AgentからLambdaを呼び出しする際に必要とする、 Lambda側での決まった実装パターンがユーティリティ化された →自前実装せずPowertoolsを使用することで、実装が大きく効率化される! ユーティリティ 概要 トレース
X-rayと連携した処理のトレース ログ 構造化ロギング メトリクス カスタム名前空間を利用したメトリクス集計 Event Handler AppSync AppSync Eventからのパブリッシュ&サブスクライブ に対するイベントハンドリング Bedrock Agent Bedrock Agentからの呼び出し に対するイベントハンドリング ※2025.6.22時点で、Pythonと.NETはBedrock Agentとの連携が対応しているようです (Javaはまだ無いようです)
Event Handler(Bedrock Agent) とは • 今回の新機能は、Powertools公式に以下の概要図で説明されています。
Event Handler(Bedrock Agent) とは • 今回の新機能は、Powertools公式に以下の概要図で説明されています。 Bedrock AgentとのIN/OUT や、 tool
useのルーティング (適切なLambdaへの誘導)
とりあえず一回動かしてみよう • 検証のために、Bedrock Agent + Lambda + Powertoolsで、 Google Books
API を使った書籍推薦エージェントを作成しました • 全体として、以下のような流れで動きます
とりあえず一回動かしてみよう デモ
Lambda実装を確認しよう // importは割愛 const app = new BedrockAgentFunctionResolver({ logger });
// Bedrock Agent – Lambda間のリゾルバ // Toolsの定義(searchBooks) app.tool<{ keywords: string, author: string }>( async ({ keywords, author }, { event }) => { try { // Tool logic const books = await searchBooks(keywords, author, 10); return books.map(book => ({ ...book })); } catch (error) { logger.error('error search books', { error }); const {sessionAttributes, promptSessionAttributes, knowledgeBasesConfiguration} = event; return new BedrockFunctionResponse({ responseState: 'FAILURE', body: 'Error search books', sessionAttributes, promptSessionAttributes, knowledgeBasesConfiguration, }); } }, { // BedrockAgentFunctionResolverが、Tool useとして識別するメタデータ name: 'searchBooks', description: 'Search for books by author or keywords', } ); export const handler = async (event: unknown, context: Context) => { return app.resolve(event as BedrockAgentFunctionEvent, context); }; まずミニマム版から
Lambda実装を確認しよう // importは割愛 const app = new BedrockAgentFunctionResolver({ logger });
// Bedrock Agent – Lambda間のリゾルバ // Toolsの定義(searchBooks) app.tool<{ keywords: string, author: string }>( async ({ keywords, author }, { event }) => { try { // Tool logic const books = await searchBooks(keywords, author, 10); return books.map(book => ({ ...book })); } catch (error) { logger.error('error search books', { error }); const {sessionAttributes, promptSessionAttributes, knowledgeBasesConfiguration} = event; return new BedrockFunctionResponse({ responseState: 'FAILURE', body: 'Error search books', sessionAttributes, promptSessionAttributes, knowledgeBasesConfiguration, }); } }, { // BedrockAgentFunctionResolverが、Tool useとして識別するメタデータ name: 'searchBooks', description: 'Search for books by author or keywords', } ); export const handler = async (event: unknown, context: Context) => { return app.resolve(event as BedrockAgentFunctionEvent, context); }; まずミニマム版から ①中間のリゾルバを作成 ②Bedrock Agentからの入力をリゾルブ ③メタデータから一致するToolを特定(今回で言えば”searchBooks”) ④-1. リゾルバから受け渡されるパラメータを受け取って、処理実行 ④-2. Bedrock Agentへ、エラーをRaise
Powertoolsを使用しないと、以下が必要 (リゾルバが無いので、)Eventから1つ1つパラメータ取得するための実装 • アクショングループ • Tool名 などなど Bedrock AgentへRaiseするExceptionクラスなどを、 自前で作成・メンテする
そもそも、Bedrock Agentからのイベントが期待する形式なのか チェックしないといけない • Eventが期待する形式か • パラメータは適切か(バリデーション) Powertoolsを導入することで、 実装の削減のみ限らず、メンテナンス性や可読性も 向上することができる!
実際に完成したLambda(コアのLog、Trace、Metricsを含む) 前半 import type { Context } from 'aws-lambda'; import
{ BedrockAgentFunctionResolver, BedrockFunctionResponse } from '@aws-lambda-powertools/event-handler/bedrock-agent'; import type { BedrockAgentFunctionEvent } from '@aws-lambda-powertools/event-handler/types'; import { Metrics, MetricUnit } from '@aws-lambda-powertools/metrics'; import { Tracer } from '@aws-lambda-powertools/tracer'; import { searchBooks } from './bookModules.js'; import { logger } from './logger.js'; const tracer = new Tracer({serviceName: 'searchBooksAgent'}); const metrics = new Metrics({namespace: 'searchBooks‘, serviceName: 'searchBooksAgent'}); const app = new BedrockAgentFunctionResolver({ logger }); // Bedrock Agent – Lambda間のリゾルバ app.tool<{ keywords: string, author: string }>( async ({ keywords, author }, { event }) => { // 以降の全ロギングに対して、以下パラメータを表示 logger.appendKeys({ keywords, author, tool: 'searchBooks' }); logger.info('searchBooks called'); try { const books = await searchBooks(keywords, author, 10); metrics.addMetric('searchBooksSucceeded', MetricUnit.Count, 1); return books.map(book => ({ ...book })); } catch (error) { トレースとメトリクスを宣言 構造化ログへのパラメータ付与 ToolUse確認のためのメトリクス集計
実際に完成したLambda(コアのLog、Trace、Metricsを含む) 後半 } catch (error) { logger.error('error search books', {
error }); metrics.addMetric('searchBooksFailed', MetricUnit.Count, 1); const {sessionAttributes, promptSessionAttributes, knowledgeBasesConfiguration} = event; return new BedrockFunctionResponse({ responseState: 'FAILURE', body: 'Error search books', sessionAttributes, promptSessionAttributes, knowledgeBasesConfiguration, }); } }, { name: 'searchBooks', description: 'Search for books by author or keywords', } ); export const handler = async (event: unknown, context: Context) => { logger.logEventIfEnabled(event); logger.setCorrelationId((event as BedrockAgentFunctionEvent).sessionId); logger.appendKeys({ requestId: context.awsRequestId }); return app.resolve(event as BedrockAgentFunctionEvent, context); }; Toolがエラーした場合にメトリクス へインクリメント (アラートと連携などできる) 複数サービス間のトレースをしやす いように、CorrelationIdを ロガーに設定 任意のキーをロガーに設定 (今回はrequestId)
LOG (Log group) • 構造的なログが得られる • 指定したキー(Ex. correlation_id, requestId)や、 パラメータ(tool,
keywords, author(今回は指定してないので無し))を自動的に出力 { "level": "DEBUG", "message": "Searching books", "timestamp": "2025-06-23T11:56:24.726Z", "service": "book-search-agent", "sampling_rate": 0, "xray_trace_id": "1-685940e8-694b07215e21870b3ea377b4", "correlation_id": "228342203262808", "requestId": "a6bc05c2-20e9-419d-ba75-f5497abcaa0b", "keywords": "[AWS 生成AI, 初心者向け, 機械学習入門]", "tool": "searchBooks", "maxResults": 10 }
Metrics (カスタム名前空間へのPUT) • Tool実行のカウントや、処理内部の部分的な実行時間(Duration)などを メトリクス化することができる • アラームやダッシュボードなどと連携することで、エージェントの運用に役立つ
TRACE (AWS X-ray) • トレースは重要。有効化しておきましょう。 • 複数のToolを構築している場合に、どのToolが呼ばれているか追跡しやすい • AgentとTool、外部APIなどとの問題切り分けに強力
まとめ • PowertoolsでBedrock Agentがサポートされるようになった • 導入することで、大幅な実装手間を削減することができ、 開発生産性に加えて、メンテナンス性や可読性を向上させることができる • さらに、従来のユーティリティ(トレース、ログ、メトリクスなど)と組み合わせることで、 Tool
の開発や運用を快適に行うことができる 生成AIエージェントの開発・運用を加速させることができる!! Powertoolsを積極活用しましょう!!
ご清聴ありがとうございました Thank you for your listening.