Building an Agentic AI Mobile Tester with Koog and Kotlin
19 Aug 2025Testing Android apps is often repetitive, time-consuming, and hard to scale. Recently, I started experimenting with agentic AI to automate mobile testing—combining Kotlin, Koog, and LLMs to build a smart tester that can execute real end-to-end scenarios.
The result is my new project: Koog - Agentic Mobile Tester.
Why I Built This
As an Android developer, I’ve used Espresso, UIAutomator, and other frameworks. They’re powerful, but still rigid: you need to write detailed test scripts and keep them updated. I wanted to explore whether an AI agent could take high-level goals like “Log in and navigate to the profile screen” and figure out the steps automatically.
How It Works
The project is powered by Koog.ai and Kotlin, using an LLM as the reasoning engine (options include Gemini, Llama, GPT, or Gwen). Here’s the flow:
Ktor API & Koog Agent (Backend)
The backend is built with Ktor in Kotlin and powered by a custom Koog agent (MobileTestAgent
) plus a toolkit of device actions (MobileTestTools
).
Ktor API
The Ktor server exposes endpoints that receive test scenarios and configuration (LLM model, temperature, iterations). Each request is routed to the MobileTestAgent
, which runs the scenario with the chosen parameters.
MobileTestAgent (Koog Agent)
MobileTestAgent
encapsulates the Koog agent setup. It translates high-level test goals into an iterative reasoning process, where the LLM plans actions like “tap login button” or “enter text”. The agent respects limits such as max iterations and temperature to balance creativity and determinism.
MobileTestTools (Device Interaction)
MobileTestTools
provides the executable layer via ADB commands. It includes functions for:
- Interactions:
tap()
,typeText()
,scroll()
,swipe()
- Checks:
assertTextVisible()
,getUiHierarchy()
- Utilities:
launchApp()
,installApk()
,takeScreenshot()
These functions are registered as tools within Koog, so when the agent plans an action, Koog calls the corresponding method directly.
Execution Flow
- Ktor receives a scenario and sends it to the agent.
- Koog plans the next step using the LLM.
- The selected
MobileTestTools
method executes the action on the device. - Feedback (UI state, success/failure) is fed back into the agent.
- This loop continues until the scenario ends or max iterations are hit.
At the end, a structured report is generated with actions, results, and optional artifacts (like screenshots), and returned to the frontend dashboard.
User Input (Frontend Dashboard)
- Users create test scenarios (goals & steps) via a ReactJS dashboard.
- The site was designed with Stitch and stores data in Cloud Firestore.
- Users can also tweak AI agent parameters like:
- Model (Gemini, GPT, etc.)
- Temperature
- Max iterations
Sample Android App
- To showcase the system, I created a simple demo Android app.
- The agent can interact with it and validate flows end-to-end.
Example Flow
-
User defines a scenario:
“Tap Add Post button → Input “some text” in the Description → Tap Create Post button” - The AI agent receives it, plans the steps, and uses ADB actions (tap, type, scroll, assert text).
- A report is generated with success/failure details.
No need to maintain test scripts—just provide the goal.
Why Kotlin + Koog?
Kotlin gave me the flexibility to build a clean API with Ktor and manage complex agent logic easily. Koog.ai, with its Model Context Protocol (MCP) integration and agentic design, allowed me to connect the LLM with Android tooling like ADB seamlessly.
This mix of Kotlin, LLMs, and Android dev tools opens a new way of thinking about mobile testing: instead of scripting, you describe intentions.
What’s Next
- Improving reporting (screenshots, videos, structured logs).
- Expanding to iOS and Web end-to-end testing.
- Exploring CI/CD integration for real-world teams.
Links
This was a fun experiment mixing Kotlin + AI agents + Android testing. If you’re curious about agentic AI, Koog, or just want to rethink mobile testing, I’d love feedback, feel free to DM on LinkedIn! 🚀