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.1k
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
正しさだけではプロジェクトは進まないから | Become an AI Agent Orchestration Engineer
yokomachi
1
34
Inside the collaboration paradox -AI駆動開発とアジャイル開発と60%と20%とハーネスと私-
yokomachi
1
230
Building a Personal AI Agent with Strands Agents × Amazon Bedrock AgentCore
yokomachi
1
53
Strands Agents × Amazon Bedrock AgentCoreで パーソナルAIエージェントを作ろう
yokomachi
3
430
身体を持ったパーソナルAIエージェントの 可能性を探る開発
yokomachi
1
220
AITuberKit+Bedrock AgentCoreで作る 3Dキャラクターエージェント
yokomachi
2
3.7k
ご飯食べながらエージェントが開発できる。そう、Agentic Engineeringならね。
yokomachi
1
490
"人"が頑張るAI駆動開発
yokomachi
1
980
AIハッカソンで1人雰囲気SDDをした学びの共有
yokomachi
1
73
Other Decks in Technology
See All in Technology
インバスケット試験対策アプリを 作って見えたAIエージェント構築 ナレッジ2選
shichijoyuhi
1
110
Swap and Memory Reclaim - Squeezing Out More RAM
ennael
PRO
1
1.5k
企業の現実世界をグラフで写し取る
sansantech
PRO
0
240
GitHub Agentic Workflows を触ってみる
htkym
2
910
覗いてみよう 関数型ビジュアル言語×2Dグラフィックスの世界
yohyamasaki
0
160
プラットフォームを「作る」、 チームに「入り込む」
sansantech
PRO
0
430
AI駆動開発、viviONの1年 ── うまくいったこと・いかなかったこと
vivion
0
130
オブザーバビリティを高める AI エージェント体験を考える / Designing AI Agent Experiences That Enhance Observability
aoto
PRO
1
170
私の推しは「聞いてから進む」AIです -AI-DLCに一人でアプリを作らせた話
yama3133
1
160
LLM機能を自作して分かるSnowflake Cortex AIの強み
nayuts
0
120
3人で1000GPU超を統合運用する?マルチクラウド&オンプレを跨ぐ、構築と運用のリアル!
kazukun0716
2
800
メルカリにおけるAI時代の高速プロトタイピング基盤「Arca」
ryotarai
18
14k
Featured
See All Featured
It's Worth the Effort
3n
188
29k
The SEO identity crisis: Don't let AI make you average
varn
0
570
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
480
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
930
Are puppies a ranking factor?
jonoalderson
2
4k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
500
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
HDC tutorial
michielstock
2
930
Test your architecture with Archunit
thirion
2
2.4k
Context Engineering - Making Every Token Count
addyosmani
9
1.2k
Visualization
eitanlees
153
17k
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