Skip to main content

Android Agent Harness

A production control plane for AI-assisted Android development

Turn a general-purpose coding agent into a predictable Android contributor with explicit developer approval, Android-aware policy, bounded project context, and evidence-backed delivery.

CI Release PyPI Python Platforms License

Why it exists · How it works · Install · Daily workflow · Safety model · Documentation


Android Agent Harness is a repository-local workflow and verification system for teams that use AI agents on real Android codebases. It does not replace Android Studio, Gradle, ADB, Git, CI, or your model. It coordinates them so the agent receives relevant context, follows an approved scope, runs proportionate checks, and cannot label work ready without evidence from the current change set.

It is designed for existing Kotlin, Java, Compose, XML, multi-module, library, dynamic-feature, and Android/KMP projects. Runtime code uses only the Python standard library.

Why it exists

Raw coding agents are useful, but Android delivery has failure modes that a prompt alone cannot reliably control:

Without the harness With the harness
The agent edits before the developer agrees on scope A task plan is recorded and explicit approval unlocks implementation
A large repository is dumped into model context Project Intelligence resolves a bounded file-, symbol-, or feature-level slice
A mixed diff is treated as one generic change Android surfaces such as Room, Compose, navigation, auth, billing, and permissions are classified independently
Every task pays for the same expensive review process Risk lanes select only the deterministic gates and specialist reviews the change needs
“Tests passed” can refer to stale or unrelated output Evidence is bound to the repository, branch, run, change set, and delivery snapshot
An old or different APK is installed Assemble, install, and launch share one verified APK artifact-set identity
Room or resource mistakes reach runtime Dedicated deterministic guards inspect migrations, localized resources, and Android-specific hazards
The agent mutates Git history or external trackers unexpectedly Client-project Git writes remain developer-owned; tracker writes require explicit, scoped authorization

The goal is not more ceremony. The goal is to spend model time and developer attention only where they materially reduce risk.

What you get

  • Approval-first execution — discovery is read-only; implementation starts only after the developer approves a concrete outcome, scope, and verification plan.
  • Android-aware change classification — detects multiple simultaneous surfaces instead of collapsing a diff to its least risky file.
  • Bounded Project Intelligence — resolves the smallest useful live context for a file or symbol, handles ambiguous identities safely, and keeps default previews compact.
  • Adaptive verification — micro, standard, and critical changes receive different gates. Presentation-only UI work is not forced through the same path as auth, billing, crypto, or Room schema changes.
  • Deterministic Android guards — localization parity, Room migration safety, test attribution, performance hazards, environment classification, Gradle diagnostics, and device identity checks.
  • Evidence-backed delivery — gate output and reviews must match the frozen final tree. Stale, partial, malformed, or mismatched evidence fails closed.
  • Safe lifecycle operations — install, update, repair, rollback, and uninstall are transactional and preserve project-owned hooks, configuration, source, and task evidence.
  • Model-agnostic operation — works with supported hosts and lets teams map abstract STANDARD and STRONG review capabilities to the models they choose.
  • Local, dependency-light runtime — installed project commands run from .agents/harness.py with no third-party Python runtime packages.

How it works

flowchart LR
    A[Discover bounded context] --> B[Draft scope and acceptance criteria]
    B --> C{Developer approves?}
    C -- No --> B
    C -- Yes --> D[Implement within approved scope]
    D --> E[Freeze change set and policy]
    E --> F[Run selected deterministic gates]
    F --> G[Run selected specialist reviews]
    G --> H[Assemble and device checks when required]
    H --> I{Evidence matches final snapshot?}
    I -- No --> D
    I -- Yes --> J[Ready for developer delivery]

The workflow is a persisted state machine:

INTAKE -> DISCOVERY -> PLAN_DRAFTED -> AWAITING_DEVELOPER_APPROVAL
       -> IMPLEMENTING -> VERIFYING -> READY_FOR_DELIVERY -> DELIVERED
                                    \-> BLOCKED -> IMPLEMENTING

The harness separates three concerns:

  1. Understanding the project — discovers modules, variants, source sets, architecture signals, symbols, and relevant dependencies without forcing an architecture rewrite.
  2. Controlling the task — binds approval, scope, risk, selected skills, and allowed operations to one task lifecycle.
  3. Proving the result — records deterministic gate and review evidence against one immutable delivery snapshot.

Install

Requirements

  • Python 3.10–3.14;
  • a Git checkout with a root Gradle Wrapper;
  • JDK and Android SDK when selected build gates require them;
  • ADB only when the task requires device verification.

Open the Android project root in your coding agent and paste this exact pinned prompt:

Read https://raw.githubusercontent.com/rabee-elkholy/android-agent-harness/v1.0.54/docs/install-or-update-prompt.md and follow all instructions.

The installer discovers the project in read-only mode, asks only the configuration questions it needs, shows the installation plan, waits for approval, installs the pinned kit, and runs Doctor. Application source is not modified during setup.

Terminal installation (alternative)

# Install the CLI in an isolated environment.
pipx install android-agent-harness

# Configure an Android project.
android-harness setup --repo /path/to/android-project

# Verify the installation and environment.
android-harness doctor --repo /path/to/android-project --json

To use a source checkout instead:

git clone --depth 1 --branch v1.0.54 --single-branch \
  https://github.com/rabee-elkholy/android-agent-harness.git ~/.android-harness/kit

python ~/.android-harness/kit/harness_cli.py setup \
  --repo /path/to/android-project \
  --kit ~/.android-harness/kit

After setup, normal work uses the repository-local launcher, so the global kit path is not required for daily commands:

python .agents/harness.py doctor --json
python .agents/harness.py task-context --file app/src/main/kotlin/com/acme/ProfileScreen.kt --json
python .agents/harness.py task status --task-id profile-edit --next

See the Quickstart and Setup Wizard reference for update, repair, rollback, uninstall, and non-interactive options.

Daily workflow

The developer can describe work naturally. A typical request is:

Add retry handling to profile loading, preserve the existing architecture, add regression coverage, and verify the affected screen.

The agent should then:

  1. resolve bounded context for the affected file, symbol, or feature;
  2. inspect the relevant application code and existing conventions;
  3. present the proposed outcome, files/surfaces, risks, tests, and device needs;
  4. wait for one explicit approval;
  5. implement the approved work without changing unrelated architecture;
  6. freeze the final change set and run the policy-selected gates and reviewers;
  7. perform assemble/device/UI verification only when the policy requires it;
  8. report the result and leave application changes unstaged for developer review.

For a bug with a meaningful deterministic seam, the workflow records a real failing result before the fix and a passing result afterward. For a documentation or mechanical change, it avoids pretending that an empty or irrelevant test run adds confidence.

Common commands

Goal Command
Diagnose installation python .agents/harness.py doctor --json
Resolve context for a file python .agents/harness.py task-context --file <path> --json
Resolve context for a symbol python .agents/harness.py task-context --symbol <name> --json
Ask for the safe next action python .agents/harness.py task status --task-id <id> --next
Run deterministic preflight python .agents/harness.py preflight
Run selected unit tests python .agents/harness.py test
Assemble a configured target python .agents/harness.py assemble <task>
Install and start verified APKs python .agents/harness.py device install-start
Verify the frozen result python .agents/harness.py verify --task-id <id>

The project includes command packs for supported hosts, but the repository-local CLI is the canonical contract.

Android-aware verification

The central policy routes checks from the actual diff. Examples:

Detected surface Typical deterministic protection
Room entity or database schema version and migration path inspection; destructive fallback detection; migration tests when configured
Localized resources key, plural, and placeholder parity; introduced hardcoded UI text checks
Compose/XML presentation resource and UI classification; proportionate visual verification
Coroutines or blocking work main-thread/blocking hazard checks plus targeted tests/review
Auth, crypto, billing, sensitive data stronger risk lane, security review, and final snapshot approval
Gradle, manifest, module topology exact module/variant discovery and build-policy checks
APK/device work artifact-set, device serial, Android user, install, and launch continuity

Example: Room schema change

If an agent adds a field to a Room entity, the harness can classify the change as ROOM_SCHEMA, discover the owning database, require an explicit migration path, run configured migration tests, route the data-focused review lane, and bind the final assemble/device evidence to the same frozen tree. A changed entity cannot be disguised as a low-risk documentation change by placing both in one diff.

Safety model

The harness is deliberately precise about what it can and cannot enforce.

Tier Meaning
HARD_ENFORCED A supported host-native hook intercepts the stated mutation class before execution
RULE_ENFORCED Instructions and deterministic delivery gates apply, but the host does not provide complete pre-execution interception
UNSUPPORTED The minimum safe workflow is unavailable for that host or capability

Important boundaries:

  • This is not an OS sandbox. A process with arbitrary local access can bypass repository files.
  • Cryptographic hashes make evidence tampering and staleness detectable; they do not make the host machine trusted.
  • The harness never claims that configuring a CI matrix proves it passed. Hosted CI results are separate evidence.
  • It does not silently modernize architecture, replace DI, migrate XML to Compose, or rewrite persistence choices.
  • It does not automatically pair wireless ADB, clear app data, uninstall an app, downgrade builds, make purchases, or grant every permission.
  • It does not commit, push, reset, or stage client application work for the developer.
  • Zoho Sprints behavior is preserved, but live tracker mutation requires explicit update zoho authorization and idempotent operation identity.

For the complete boundary and threat analysis, read Security, Threat Model, and Compatibility Matrix.

Supported project and host shapes

The validated project boundary includes:

  • Kotlin, Java, and mixed projects;
  • Jetpack Compose, XML Views, and hybrid UI;
  • application, library-only, multi-module, dynamic-feature, and Android/KMP targets;
  • Kotlin or Groovy Gradle DSL;
  • discovered flavors and custom build types;
  • existing tests, no-test repositories, and explicitly recorded baseline debt;
  • normal Git checkouts and worktrees;
  • Linux, macOS, and Windows hosts.

Host adapters are available for Claude Code, GitHub Copilot, Cursor, Windsurf, Roo Code, Gemini CLI, and Antigravity. Enforcement strength depends on the capabilities of each host; see Tool Support for the current matrix.

Lifecycle and non-interference

Harness lifecycle operations are designed not to take ownership of the Android project:

  • managed files live under .agents/ plus documented host adapters;
  • local state is excluded through .git/info/exclude rather than changing the application’s tracked ignore policy;
  • project-owned hooks and Git configuration are preserved byte-for-byte;
  • same-major updates are transactional and fail closed on conflicting managed-file edits;
  • repair restores immutable engine files from the pinned checksum inventory;
  • uninstall starts as a dry run and preserves modified harness material in recovery when applied;
  • interrupted lifecycle operations use journals for deterministic recovery.
android-harness update --repo /path/to/android-project --kit /path/to/new-kit
android-harness repair --repo /path/to/android-project --kit /path/to/pinned-kit
android-harness uninstall --repo /path/to/android-project
android-harness uninstall --repo /path/to/android-project --apply

Verification and release quality

This repository verifies the harness itself; it does not run Android Gradle or ADB against the harness source tree.

# Complete deterministic suite.
python harness_cli.py selftest

# Syntax validation.
python -m compileall -q harness_cli.py agents/scripts agents/mcp/zoho_sprints

# Release metadata, prompt pins, checksums, and package contract.
python scripts_dev/validate_release.py

CI runs the complete selftest suite across every supported Python version on Linux and on the canonical Python runtime for Windows and macOS. Wheel install/update/uninstall lifecycles run separately on all three operating systems, alongside performance regression and release-metadata checks. Release tags receive a second cross-platform validation before trusted PyPI publication.

Documentation

Document Use it for
Quickstart installation and first successful run
Architecture components, state, policy, and evidence design
Workflows the full task and delivery lifecycle
Compatibility Matrix supported projects, runtimes, and enforcement boundaries
Tool Support AI-host adapters and capability tiers
Setup Wizard configuration questions and generated policy
Threat Model trust assumptions, attacks, and residual risks
Restore and Recovery damaged installation recovery and verification
Contributing development, tests, and release rules
Changelog release history and migration notes

What this project is not

  • not an AI model, model proxy, or provider lock-in layer;
  • not a replacement for Gradle, Android Studio, Git, CI, or human code review;
  • not a generic autonomous-agent swarm framework;
  • not a promise that every host offers hard pre-execution enforcement;
  • not a reason to run every expensive gate for every trivial edit.

Contributing

Issues and focused pull requests are welcome. Please read CONTRIBUTING.md, preserve the standard-library-only runtime, add deterministic regression coverage for behavior changes, and run the complete selftest before opening a pull request.

Security issues should follow the private reporting process in SECURITY.md.

License

Apache License 2.0. See LICENSE.

Release files for android-agent-harness 1.0.54

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for android-agent-harness 1.0.54
File Size Uploaded
android_agent_harness-1.0.54.tar.gz 534.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for android-agent-harness 1.0.54
File Interpreter ABI Platform
android_agent_harness-1.0.54-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / android_agent_harness-1.0.54.tar.gz

Download URL android_agent_harness-1.0.54.tar.gz
Size 534.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2ea38122ef83342dc438417665a2650a745a592f92dd11902ea9a45cbbfc1469
BLAKE2b-256 checksum
How to use checksums
6465614f4ab140f31ee1d12f441795003386bcba0336db059c794bbd8460ba38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / android_agent_harness-1.0.54-py3-none-any.whl

Download URL android_agent_harness-1.0.54-py3-none-any.whl
Size 621.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a3f393a4a338e6395706939d151ab90ccfb434203999d9172d55ae57db85e3d
BLAKE2b-256 checksum
How to use checksums
c9fbf19b4e71a02a24fb52865d89ad04fb1d3dde1c0b7341a5e70fe9ae1d6269
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.0

2 release files

1.0.60

2 release files

1.0.59

2 release files

1.0.58

2 release files

1.0.57

2 release files

1.0.56

2 release files

1.0.55

2 release files

This release

1.0.54 This release

2 release files

1.0.53

2 release files

1.0.52

2 release files

1.0.51

2 release files

1.0.50

2 release files

1.0.48

2 release files

1.0.47

2 release files

1.0.46

2 release files

1.0.45

2 release files

1.0.44

2 release files

1.0.43

2 release files

1.0.42

2 release files

1.0.41

2 release files

1.0.40

2 release files

1.0.39

2 release files

1.0.38

2 release files

1.0.37

2 release files

1.0.36

2 release files

1.0.35

2 release files

1.0.34

2 release files

1.0.33

2 release files

1.0.32

2 release files

1.0.31

2 release files

1.0.30

2 release files

1.0.29

2 release files

1.0.28

2 release files

1.0.26

2 release files

1.0.25

2 release files

1.0.24

2 release files

1.0.23

2 release files

1.0.22

2 release files

1.0.21

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page