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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
24
Inside the collaboration paradox -AI駆動開発とアジャイル開発と60%と20%とハーネスと私-
yokomachi
1
220
Building a Personal AI Agent with Strands Agents × Amazon Bedrock AgentCore
yokomachi
1
50
Strands Agents × Amazon Bedrock AgentCoreで パーソナルAIエージェントを作ろう
yokomachi
3
400
身体を持ったパーソナルAIエージェントの 可能性を探る開発
yokomachi
1
210
AITuberKit+Bedrock AgentCoreで作る 3Dキャラクターエージェント
yokomachi
2
3.5k
ご飯食べながらエージェントが開発できる。そう、Agentic Engineeringならね。
yokomachi
1
480
"人"が頑張るAI駆動開発
yokomachi
1
960
AIハッカソンで1人雰囲気SDDをした学びの共有
yokomachi
1
70
Other Decks in Technology
See All in Technology
synctest時代のhttptest Go 1.27で変わるHTTPサーバテストの裏側 / go conference2026 synctest and httptest
budougumi0617
1
2.6k
GoにおけるFFIのこれまでとこれから
goccy
5
2.3k
コスト最適化の「めんどくさい」を AWS FinOps Agent でチョット楽にする
classmethod_kaz
0
300
Sigmaユーザーのための有用リソース一挙公開 & Sigmaで使えるMCP #sigma_ucj /useful-resources-for-sigma-computing-users-and-mcps-with-sigma
shinyaa31
0
180
Gitは怖い?共有ワークスペースから始めるSnowflakeチーム開発
coco_se
0
110
Omarchy Quattro の日本語設定周り
simosako
2
140
AI活用の現在地、 ちゃんと見えてますか?/XPfest-2026
visional_engineering_and_design
0
180
AIに丸投げしないトイル削減 / Eliminating Toil Without Leaving It All to AI
kohbis
4
1.1k
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
4
25k
[2026-09-11]SREは誰のもの?運用エンジニアが始める 「SRE領域への越境」とチームの進化の軌跡 〜Road to NEXT CRE
tosite
0
120
『止めない』を設計する — 制約の中で、事業の根幹を支える判断
hiroyaterui
0
260
From Vanilla Kubernetes to a Batteries-Included Platform: Developer Experience at 1,300+ Clusters
yosshi_
0
680
Featured
See All Featured
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
330
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
57k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
590
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Abbi's Birthday
coloredviolet
3
9.9k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
320
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
440
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
190
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
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