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
ゆるーく理解するKoogのAIAgent開発
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
kk__777
October 23, 2025
72
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ゆるーく理解するKoogのAIAgent開発
https://love-kotlin.connpass.com/event/369603/
kk__777
October 23, 2025
More Decks by kk__777
See All by kk__777
マンガアプリViewerの大画面対応を考える
kk__777
0
720
「GigaViewer For Apps」の単体テストを振り返る
kk__777
0
1.1k
KSPの話がしたい!
kk__777
0
52
KSPの話がしたい
kk__777
0
140
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
500
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Odyssey Design
rkendrick25
PRO
2
810
Leo the Paperboy
mayatellez
10
2.3k
Amusing Abliteration
ianozsvald
1
300
How to Ace a Technical Interview
jacobian
281
24k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
360
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
890
Skip the Path - Find Your Career Trail
mkilby
1
230
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Believing is Seeing
oripsolob
1
220
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
Transcript
ゆるーく理解する Koog のAIAgent 開発 kk__777 株式会社 はてな モバイルアプリエンジニア(おもにAndroid )
Kotlin でAI エージェントを構築・実行 JetBrains 製オープンソースフレームワーク エージェントの種類、LLM 切替、履歴圧縮、永続化、KMP 対応、Spring/Ktor 統 合、
OpenTelemetry 観測などを備え、ツール連携と複雑なワークフローを型安全 なDSL で扱える Learn more 🧠 Koog
色々書いてあるけどとりあえず Kotlin でAi Agent 作れるやつだよ
ログイン画面でログインする ↓ ログイン成功でホーム画面で何かを表示 ↓ ホーム画面でなんらかの操作ができる ↓ ホーム画面から詳細画面に遷移する とりあえずなんか作ってみる
とりあえずなんか作ってみる 🤖 君は家計簿アプリのデータを管理している Agent だ よ データの取得・フィルター・集計・詳細取得など、与えられた命令に応 じて 必要なツールを選び、整形した結果を返すのが役割。 #
認証 # 一覧取得 # 詳細参照
たとえばこんな命令 このユーザid でログインして ホーム表示したよデータちょうだい ホームのデータ、特定の月でフィルターして この項目のid の詳細情報ちょうだい
たとえばこんな命令 agent.run("demo_user でログインして") agent.run(" ホームを表示したよ。全取引データをください") agent.run("2025/11 でフィルターしたデータをください") agent.run("id 001 の詳細データをください。")
デモのお時間
Tool の提供 Strategy の提供 Agent Config の設定 今回やったこと
実行 agent.run( AgentRequest( // 開発者で定義したdata class screen = Screen.Login.name, instruction
= "ユーザー名「$username」でログインしてください", parameters = mapOf("username" to username) ) ) agent.run( AgentRequest( screen = Screen.Home.name, instruction = "ホーム画面のデータを取得してください" ) ) agent.run( AgentRequest( screen = Screen.Monthly.name, instruction = "${year}年${month}月のデータを取得してください", parameters = mapOf("year" to year.toString(), "month" to month.toString()) ) )
interface AIAgent<Input, Output>
ツール エージェントが外部の世界(API ・DB ・OS など)とやり取りするための実行インターフェース @LLMDescription("家計簿アプリのツールセット。ログイン、ユーザー情報取得、取引データ管理の機能を提供します。") class BudgetTools : ToolSet
{ @Tool @LLMDescription("指定されたユーザー名でログインします。成功時はユーザー情報を含む成功メッセージを、失敗時はエラーメッセージを返します。 fun loginUser( @LLMDescription("ログインするユーザー名。有効なユーザー名: demo_user, test_user, sample_user") username: String ): String { . } @Tool @LLMDescription("取引データを取得します。yearとmonthを指定すると、その月の取引のみを返します。省略すると全ての取引を返します。") fun getTransactions( @LLMDescription("年(例: 2024)。省略可能 - 省略すると全ての取引を取得します。") year: Int?, @LLMDescription("月(1-12)。省略可能 - yearと一緒に指定する必要があります。") month: Int? ): String { . } .
Strategy エージェントが“ どう考え、どう行動するか” を定義する設計図 val strategy = strategy<AgentRequest, LoginResponse>("login") {
// 事前準備として clientからのリクエストにコンテキスト(画面名とか今のユーザ名とか)を加えてる val prepareRequest by node<AgentRequest, String> { request -> "画面: ${request.screen}\nユーザー名: ${request.parameters["username"]}\n指示: ${request.instruction}" } // 構造化レスポンスの作成を誘発する val responseNode by nodeLLMRequestStructured<LoginResponse>( fixingParser = StructureFixingParser( fixingModel = OpenAIModels.CostOptimized.GPT4oMini, retries = 2 ) ) // 組み合わせ nodeStart then prepareRequest then responseNode edge(responseNode forwardTo nodeFinish transformed { it.getOrThrow().structure }) }
Agent Config の設定 agentConfig = AIAgentConfig( prompt = prompt("budget_app") {
system( """ あなたは家計簿アプリのアシスタントです。 ユーザーの画面情報と指示を受け取り、適切なツールを使ってデータを取得・処理してください。 """.trimIndent() ) }, maxAgentIterations = 20 val agent = AIAgent( promptExecutor = simpleOpenAIExecutor(apiKey), // LLM model = OpenAIModels.Chat.GPT4o, // モデル strategy = strategy, // Strategy toolRegistry = ToolRegistry { tools(BudgetTools().asTools()) // Toolの設定 }, ), )
おもしろポイント① あなたは家計簿アプリのアシスタントです。 ユーザーの画面情報と指示を受け取り、適切なツールを使ってデータを取得・処理してください。 Tool を渡すとそれがどんなものかを認識してくれているから、指示に応じて適切なものを 考えて使ってくれる Tool を選択して 動いていくプロセスを Strategy
である程度拡張できる Agent へのシステムプロンプトがこれだけ。 (2 行目もたぶん消しても動く気がする)
おもしろポイント② マルチプラットフォーム iOS Android 0:00 JVM
おもしろポイント③ 🟢 Input ( ユーザID ・月など) 🔧 Tool (MCP /
API / Dummy Data) 📊 Output ( 整形済みデータ) Tool による拡張 今回はダミーデータを返しているだけだが、MCP を使っても API を使っても OK 。 要は「Input → Output 」の関係を伝えておけば中身を意識せずに Agent が適切に使っ てくれる。
Ai Agent のアイデアをください!!! ご清聴ありがとうございました。