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
Code Interpreter で、AIに安全に コードを書かせる。
Search
yoko / Naoki Yokomachi
April 17, 2026
Technology
9.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Code Interpreter で、AIに安全に コードを書かせる。
yoko / Naoki Yokomachi
April 17, 2026
More Decks by yoko / Naoki Yokomachi
See All by yoko / Naoki Yokomachi
Two A's for Weekly Releases | 少人数チームが週1リリースを継続するためのPJのコンテキスト化とClaude Code活用開発フロー
yokomachi
1
75
正しさだけではプロジェクトは進まないから | Become an AI Agent Orchestration Engineer
yokomachi
1
43
Inside the collaboration paradox -AI駆動開発とアジャイル開発と60%と20%とハーネスと私-
yokomachi
1
250
Building a Personal AI Agent with Strands Agents × Amazon Bedrock AgentCore
yokomachi
1
56
Strands Agents × Amazon Bedrock AgentCoreで パーソナルAIエージェントを作ろう
yokomachi
3
440
身体を持ったパーソナルAIエージェントの 可能性を探る開発
yokomachi
1
240
AITuberKit+Bedrock AgentCoreで作る 3Dキャラクターエージェント
yokomachi
2
3.8k
ご飯食べながらエージェントが開発できる。そう、Agentic Engineeringならね。
yokomachi
1
500
"人"が頑張るAI駆動開発
yokomachi
1
990
Other Decks in Technology
See All in Technology
古い指輪から広がった JAVA コミュニティ とのつながり
yamad
0
140
オントロジーって 結局なにもの? AI エージェントに「意味」を渡す知識設計の話
greenmidori
0
260
AIをリアル世界に解き放つ 〜M5Stack×AIであなたのアイディアを手の平に〜
hamadakoji
1
280
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
220
AI駆動で「他アプリの音を加工できる」アプリを作った
satomasahiro2005
0
190
FinOps Agentが生んだ技術負債:コスト自動調査の落とし穴と解消までの道のり
oasis1994liveforever
3
250
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
370
CloudWatch Logsのコスト最適化:どこまでAIに任せてどこから人間が承認すべきか
yama3133
0
150
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
410
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
780
『SAR衛星データ解析入門』のご紹介とその応用
syuchimu
0
140
DevelopersIO2026 -バックアップは“消されないこと”が9割-
yoshida0129
0
280
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
590
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
WENDY [Excerpt]
tessaabrams
14
40k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
630
Why Our Code Smells
bkeepers
PRO
340
58k
Discover your Explorer Soul
emna__ayadi
2
1.3k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
640
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
530
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
370
Transcript
LT · 5 min · 2026.04 AMAZON BEDROCK AGENTCORE Code
Interpreter で、 AIに安全に コードを書かせる。 yoko / Naoki Yokomachi Strands Agents × AgentCore で作る可視化ワークフロー zenn.dev/yokomachi
ABOUT ME 個人開発で AIエージェントを作っています。 TONaRi パーソナルAIエージェント。 基本構成は Strands Agents +
Amazon Bedrock AgentCore。 テックニュースの投稿などもXで発信中。 Blog / Zenn AWS・AIエージェントまわりを書いています。 今日は最近書いた記事を元に、 Code Interpreter の実装例を紹 介します。 zenn.dev/yokomachi 01 — About yoko / Naoki Yokomachi
TODAY 今日の5分で話すこと 01 AgentCore Code Interpreter とは AIに安全にコードを書かせる AWS のビルディングブロック
02 Strands Agents の Skills と組み合わせる 手順を SKILL.md に外出しして、 動的にロードする仕組み 03 AWSコスト可視化ワークフロー Cost Explorer → Code Interpreter → matplotlib → S3 02 — Agenda 5 min talk
01 · THE BUILDING BLOCK AgentCore Code Interpreter AgentCore Runtime
上のエージェントが、 サンドボックス環境で安全にコードを実行できるビルディングブロック。 MENTAL MODEL AIが書いたコードを、 そのまま自分のマシンで動かすのは怖い。 その "怖い部分" を AWS に丸ごと預けられる、 と 考えると分かりやすい。 SANDBOX — ap-northeast-1 # エージェントが書いた Python import pandas as pd import matplotlib.pyplot as plt ... # ↑ を隔離環境で実行して結果だけ返す → stdout / stderr / 生成ファイル がエージェントに返る 03 — Code Interpreter docs: AWS ML Blog
01 · FEATURES 特徴は3つ 01 サンドボックス環境で 安全に実行 エージェントが生成した Python を、
隔離環境 でそのまま走らせる。 ホスト環境への影響ゼ ロ。 isolation 02 プリインストール済み ライブラリ pandas / numpy / matplotlib などの定 番が最初から使える。 セットアップ不要。 batteries included 03 ユーザー定義の ネットワーク デフォルトは制限付き。 必要なら、 パブリックア クセスや VPC 接続のある環境も定義できる。 custom env 04 — Features sandbox / libs / network
02 · STRANDS AGENTS Skills — 手順を外に出す Anthropic 提案の仕組みが、 Strands
Agents でも使えるようになった (2026.03)。 手順は SKILL.md に書き、 メタデータだけシステムプロンプトに注入。 必要になったタイミングで、 エージェントが動的にロードして実行する。 → トークン節約 & コンテキスト汚染の抑制 skills/aws-cost/SKILL.md --- name: aws-cost description: Analyze and visualize AWS cost data with get_aws_cost & execute_python for matplotlib charts allowed-tools: get_aws_cost execute_python --- # AWS Cost Analysis Skill Two-step process: fetch data, then visualize. ## Critical Rules - NEVER call plt.savefig() - NEVER call plt.close() - Use English for ALL chart text 05 — Skills Anthropic → Strands Agents
03 · WORKFLOW 作ったもの — AWSコスト可視化 USER 「今月のAWSコスト教えて」 ↓ AGENT
Strands Agents · Main Agent ① skills — SKILL.md をロード ② get_aws_cost — Cost Explorer API ③ execute_python 3-1 Code Interpreter で matplotlib → PNG 3-2 S3 アップロード → 署名付き URL ↓ UI チャットに画像をインライン表示 06 — Workflow user · agent · tools · UI
03 · IMPLEMENTATION キモ: execute_python エージェントが書いたコードの前後にキャプチャ用コードを自動注入して、 生成された matplotlib 画像を確実に回収する。 @tool
def execute_python(code: str) -> str: img_code = f""" import matplotlib matplotlib.use('Agg') {code} # ← エージェントが生成したコード import matplotlib.pyplot as plt, base64, io, json as _json _imgs = [] for _i in plt.get_fignums(): # ← 開いている figure を全部拾う _b = io.BytesIO() plt.figure(_i).savefig(_b, format='png', bbox_inches='tight', dpi=100) _imgs.append({{'i': _i, 'd': base64.b64encode(_b.getvalue()).decode()}}) print('_IMG_' + _json.dumps(_imgs) + '_END_') """ with code_session(CODE_INTERPRETER_REGION) as client: resp = client.invoke("executeCode", {"code": img_code, ...}) # stdout の _IMG_..._END_ から画像を抽出 → S3 へ 07 — execute_python auto-inject capture
03 · DEMO 動かすとこんな感じ USER 先月のAWSコスト、 サービス別で棒グラフにして。 AGENT › skills:
aws-cost をロード › get_aws_cost(months=1, group_by_service=True) › execute_python(...matplotlib...) 先月は合計 $142.80。 内訳はこちらです → aws_cost_2026_03.png via S3 presigned URL $60 $30 $0 Bedrock EC2 S3 Lambda CloudW. Other AWS Cost by Service — 2026/03 08 — Demo S3 URL → inline image
WRAP-UP 持ち帰ってほしい3つ CODE INTERPRETER AIに安全に Python を実行させる AWS のサンドボックス。 matplotlib
も最初から入っているので、 データ分析との相 性が良い。 SKILLS 手順を Markdown で外出し、 必要な 時だけロード。 プロンプト肥大化・コンテキスト汚染を避けながら複雑な手 順を扱える。 COMBINED データ取得 → 可視化まで、 一気通貫 でエージェントに任せられる。 今回はデフォルト環境。 ユーザー定義環境なら、 さらに自由 度が上がる。 Blog: Strands Agents Skill と AgentCore Code Interpreter で AWS コストの可視化ワークフローを作る zenn.dev/yokomachi 09 — Takeaway safe · scoped · end-to-end
END · THANK YOU ありがとう。 yoko / Naoki Yokomachi ·
zenn.dev/yokomachi · x.com/tonari_with