Skip to content

20 AI testers on 20 different phones, in parallel, on GitHub's free runners: Claude Code agents on iOS Simulators and Android emulators that find broken flows, translation, layout and accessibility bugs

Clearer first run: how each agent ended on the run page, setup.sh checks what you paste, feedback and teams forms

Pierre RAFFALLIaa69f3f39007
diff --git a/.github/ISSUE_TEMPLATE/teams.yml b/.github/ISSUE_TEMPLATE/teams.yml
new file mode 100644
index 0000000..43e6c76
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/teams.yml
@@ -0,0 +1,41 @@
+name: Hosted version for teams
+description: Three questions about a hosted version with macOS runners for private repos and a shared dashboard.
+title: "[Teams] "
+labels: ["teams"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ I'm exploring a hosted version for teams. Three questions, one minute. This issue is public: write to me on [LinkedIn](https://www.linkedin.com/in/pierre-raffalli/) for anything you would rather not post here.
+ - type: dropdown
+ id: team
+ attributes:
+ label: How many mobile developers on your team?
+ options:
+ - "1"
+ - 2 to 5
+ - 6 to 20
+ - More than 20
+ validations:
+ required: true
+ - type: dropdown
+ id: stack
+ attributes:
+ label: Your stack
+ multiple: true
+ options:
+ - Flutter
+ - React Native or Expo
+ - Native iOS
+ - Native Android
+ - Kotlin Multiplatform
+ - Other
+ validations:
+ required: true
+ - type: textarea
+ id: blocker
+ attributes:
+ label: What stops you from running it in your CI today?
+ description: macOS minutes on a private repo, sharing the reports with the team, setup time, a security review, model costs...
+ validations:
+ required: true
diff --git a/.github/ISSUE_TEMPLATE/usage-feedback.yml b/.github/ISSUE_TEMPLATE/usage-feedback.yml
new file mode 100644
index 0000000..1f405c1
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/usage-feedback.yml
@@ -0,0 +1,47 @@
+name: Usage and feedback
+description: Ran it on your app? Share what the agents found and what got in the way.
+title: "[Usage] "
+labels: ["usage"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ Thanks for trying it. This issue is public: leave out anything private about your app (report contents you would not post, screenshots of unreleased screens, tokens).
+ - type: dropdown
+ id: stack
+ attributes:
+ label: Your app
+ options:
+ - Flutter
+ - React Native
+ - Expo
+ - Native Kotlin or Java
+ - Native Swift or Objective-C
+ - Kotlin Multiplatform
+ - Capacitor or Ionic
+ - .NET MAUI
+ - Prebuilt APK or .app
+ - Other
+ validations:
+ required: true
+ - type: input
+ id: phones
+ attributes:
+ label: Phones
+ placeholder: "4: 2 Android, 2 iOS"
+ - type: textarea
+ id: found
+ attributes:
+ label: What did the agents find?
+ description: How many issues, how many were real, the best catch, the false alarms.
+ validations:
+ required: true
+ - type: textarea
+ id: setup
+ attributes:
+ label: What got in the way?
+ description: The step where you got stuck, an error message, something the README did not say.
+ - type: input
+ id: link
+ attributes:
+ label: App or run link (optional)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 80266a4..2e52aae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
## Unreleased
+- **How each agent ended, on the run page**: finished, out of turns, usage limit, refused token or key, no API credit, rate limit or overloaded API, as an annotation with what to do next, plus turns and cost in the job summary. Nothing the agent wrote is printed, since public logs are public. `collect.sh` prints the same line for each agent ([scripts/agent_status.py](scripts/agent_status.py)).
+- **setup.sh**: asks again after an empty paste or a wrong choice, checks an API key with Anthropic before saving it (a free call, the key never on the command line), warns when a token does not look like one and when the repo is private, where macOS minutes count ten times. `setup.ps1` does the same, except the online check.
+- **Feedback**: issue forms to share how a run went on your app, and three questions about a hosted version for teams.
- **Cheaper models**: `model=haiku`, or any Anthropic-compatible API (OpenRouter, DeepSeek, Kimi, GLM, MiniMax, Qwen) with the new `llm_base_url` input and an `LLM_API_KEY` secret ([scripts/llm_env.sh](scripts/llm_env.sh)). The findings depend on how well the model reads screenshots and reasons: [docs/cheaper-models.md](docs/cheaper-models.md).
- **Improvement report**: with [briefs/improve.md](briefs/improve.md), each persona uses the app once to reach its goal, then lists what to change first, by area and impact. SUMMARY.md starts with the goals reached, the actions and the scores, then the improvements.
- **Compare two versions**: `scripts/compare.py` puts two runs of the same personas side by side (two branches, two builds): goals reached, actions, scores, issues seen on one version only, improvements by area ([docs/compare-versions.md](docs/compare-versions.md)).
diff --git a/README.es.md b/README.es.md
index 4ceca3d..0dcbac4 100644
--- a/README.es.md
+++ b/README.es.md
@@ -177,6 +177,12 @@ Sí. Una persona son unas pocas líneas en [personas.json](personas.json): dispo
A veces interpreta mal una pantalla: 3 de los 20 agentes de LocalSend señalaron el teclado en inglés del simulador como parte de la app. Unos minutos por agente cubren los caminos principales, no cada rincón de una app grande. Cada hallazgo viene con capturas numeradas, así que revísalas antes de reportar nada.
+## Versión alojada para equipos (en estudio)
+
+El flujo de este repo sigue siendo gratis, de código abierto y completo. Estoy estudiando una versión alojada para equipos con apps privadas: runners de macOS incluidos (en un repo privado, GitHub cuenta cada minuto de macOS diez veces) y un panel web para compartir los informes con todo el equipo, product managers incluidos.
+
+¿Le serviría a tu equipo? [Responde tres preguntas](https://github.com/pierridotite/mobile-agent-testers/issues/new?template=teams.yml) o [escríbeme por LinkedIn](https://www.linkedin.com/in/pierre-raffalli/). ¿Ya lo probaste con tu app? [Cuéntame qué encontró y qué te frenó](https://github.com/pierridotite/mobile-agent-testers/issues/new?template=usage-feedback.yml).
+
## Historial de estrellas
[![Star History Chart](https://api.star-history.com/svg?repos=pierridotite/mobile-agent-testers&type=Date)](https://star-history.com/#pierridotite/mobile-agent-testers&Date)
diff --git a/README.ja.md b/README.ja.md
index 2edfcd7..4c0cbdd 100644
--- a/README.ja.md
+++ b/README.ja.md
@@ -175,6 +175,12 @@ gh workflow run agent-testers.yml -f source_repo=you/app -f app_id=com.you.app \
画面を読み違えることがあります:LocalSend では 20 のエージェントのうち 3 つが、シミュレーターの英語キーボードをアプリの一部だと報告しました。エージェントごとの探索は数分なので、主な操作の流れはカバーしても、大きなアプリの隅々まではカバーしません。どの指摘にも番号付きのスクリーンショットが付くので、報告する前に確認してください。
+## チーム向けホスト版(検討中)
+
+このワークフローは今後も無料・オープンソースのまま、機能もすべてそろっています。非公開アプリを持つチーム向けに、ホスト版を検討しています。macOS ランナー込み(非公開リポジトリでは、GitHub は macOS の 1 分を 10 分として数えます)で、レポートをプロダクトマネージャーも含めたチーム全員と共有できる Web ダッシュボード付きです。
+
+チームの役に立ちそうですか? [3 つの質問に答える](https://github.com/pierridotite/mobile-agent-testers/issues/new?template=teams.yml)か、[LinkedIn で連絡してください](https://www.linkedin.com/in/pierre-raffalli/)。もう自分のアプリで試しましたか? [見つかったことと、つまずいたところを教えてください](https://github.com/pierridotite/mobile-agent-testers/issues/new?template=usage-feedback.yml)。
+
## スターの推移
[![Star History Chart](https://api.star-history.com/svg?repos=pierridotite/mobile-agent-testers&type=Date)](https://star-history.com/#pierridotite/mobile-agent-testers&Date)
diff --git a/README.md b/README.md
index e02da8a..e92b206 100644
--- a/README.md
+++ b/README.md
@@ -176,6 +176,12 @@ Yes. A persona is a few lines in [personas.json](personas.json): device, OS vers
It sometimes misreads a screen: 3 of LocalSend's 20 agents flagged the Simulator's English keyboard as part of the app. A few minutes per agent covers the main paths, not every corner of a big app. Every finding comes with numbered screenshots, so check them before filing anything.
+## Hosted version for teams (exploring)
+
+The workflow here stays free, open source and complete. I'm exploring a hosted version for teams with private apps: macOS runners included (on a private repo, GitHub counts each macOS minute ten times) and a web dashboard to share the reports with the whole team, product managers included.
+
+Would that help your team? [Answer three questions](https://github.com/pierridotite/mobile-agent-testers/issues/new?template=teams.yml) or [write to me on LinkedIn](https://www.linkedin.com/in/pierre-raffalli/). Already ran it on your app? [Tell me what it found and what got in the way](https://github.com/pierridotite/mobile-agent-testers/issues/new?template=usage-feedback.yml).
+
## Star history
[![Star History Chart](https://api.star-history.com/svg?repos=pierridotite/mobile-agent-testers&type=Date)](https://star-history.com/#pierridotite/mobile-agent-testers&Date)
diff --git a/README.pt-BR.md b/README.pt-BR.md
index 1c1f98c..99941fd 100644
--- a/README.pt-BR.md
+++ b/README.pt-BR.md
@@ -177,6 +177,12 @@ Sim. Uma persona são algumas linhas no [personas.json](personas.json): aparelho
Às vezes lê uma tela errado: 3 dos 20 agentes do LocalSend apontaram o teclado em inglês do simulador como parte do app. Alguns minutos por agente cobrem os caminhos principais, não cada canto de um app grande. Cada bug relatado vem com capturas numeradas, então confira antes de abrir qualquer issue.
+## Versão hospedada para equipes (em estudo)
+
+O fluxo deste repositório continua gratuito, de código aberto e completo. Estou estudando uma versão hospedada para equipes com apps privados: runners macOS incluídos (num repositório privado, o GitHub conta cada minuto de macOS dez vezes) e um painel web para compartilhar os relatórios com a equipe toda, product managers incluídos.
+
+Isso ajudaria a sua equipe? [Responda três perguntas](https://github.com/pierridotite/mobile-agent-testers/issues/new?template=teams.yml) ou [fale comigo no LinkedIn](https://www.linkedin.com/in/pierre-raffalli/). Já rodou no seu app? [Conte o que ele encontrou e o que atrapalhou](https://github.com/pierridotite/mobile-agent-testers/issues/new?template=usage-feedback.yml).
+
## Histórico de estrelas
[![Star History Chart](https://api.star-history.com/svg?repos=pierridotite/mobile-agent-testers&type=Date)](https://star-history.com/#pierridotite/mobile-agent-testers&Date)
diff --git a/README.zh-CN.md b/README.zh-CN.md
index a286f9f..8a66867 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -174,6 +174,12 @@ gh workflow run agent-testers.yml -f source_repo=you/app -f app_id=com.you.app \
它有时会看错屏幕:LocalSend 的 20 个智能体中有 3 个把模拟器的英文键盘当成了应用的一部分。每个智能体只探索几分钟,覆盖主要路径,而不是大型应用的每个角落。每个发现都附带编号截图,提交之前请先核对。
+## 团队托管版(探索中)
+
+这里的工作流会一直免费、开源、完整。我正在探索一个面向私有应用团队的托管版:包含 macOS 运行器(在私有仓库里,GitHub 把 macOS 的每一分钟按十分钟计算),以及一个网页面板,方便把报告分享给整个团队,包括产品经理。
+
+对你的团队有用吗?[回答三个问题](https://github.com/pierridotite/mobile-agent-testers/issues/new?template=teams.yml),或[在 LinkedIn 上联系我](https://www.linkedin.com/in/pierre-raffalli/)。已经在你的应用上跑过了?[告诉我它发现了什么、哪里卡住了](https://github.com/pierridotite/mobile-agent-testers/issues/new?template=usage-feedback.yml)。
+
## Star 历史
[![Star History Chart](https://api.star-history.com/svg?repos=pierridotite/mobile-agent-testers&type=Date)](https://star-history.com/#pierridotite/mobile-agent-testers&Date)
diff --git a/scripts/agent_status.py b/scripts/agent_status.py
new file mode 100644
index 0000000..a3c86d1
--- /dev/null
+++ b/scripts/agent_status.py
@@ -0,0 +1,118 @@
+"""Says how an agent's `claude -p` run ended, without printing anything it wrote.
+
+The workflow's logs are public, so this reads results/agent-output.json and
+results/agent-errors.txt (both encrypted later with the rest of the results)
+and only prints a status: finished, out of actions, usage limit, refused token
+or key, no API credit, rate limit, overloaded API, or no output.
+
+On GitHub Actions (GITHUB_ACTIONS=true) it adds an annotation for each problem,
+shown on the run page, and one row to the job summary. Elsewhere, like in
+scripts/collect.sh, it prints one plain line.
+Usage: python3 scripts/agent_status.py <agent-output.json> <agent-errors.txt> <persona>"""
+import json, os, re, sys
+
+# (status, regex on the agent's final message and its stderr), first match wins
+PATTERNS = [
+ ("usage_limit", r"hit your (?:[\w-]+ )?limit|usage limit|limit reached|weekly limit"),
+ ("auth", r"invalid api key|authentication_error|oauth token|please run /login|api error: 401|"
+ r"invalid bearer token|not logged in"),
+ ("credit", r"credit balance is too low|insufficient[_ ](?:credit|balance|quota)|billing"),
+ ("rate_limit", r"rate_limit_error|api error: 429|too many requests"),
+ ("overloaded", r"overloaded_error|api error: 529|overloaded"),
+]
+PROBLEMS = {
+ "usage_limit": ("warning", "stopped on a Claude usage limit",
+ "Your plan's usage limit was reached. Wait for the reset, then run fewer personas at once "
+ "(android_personas, ios_personas)."),
+ "auth": ("error", "could not sign in to the model API",
+ "The token or key was refused. Set it again with: gh secret set {secret}"),
+ "credit": ("error", "found no API credit",
+ "The API account has no credit left. Add some, or use a Claude subscription token: "
+ "gh secret set CLAUDE_CODE_OAUTH_TOKEN (token from claude setup-token)."),
+ "rate_limit": ("warning", "hit the API rate limit",
+ "Requests were refused for too long (429). Run fewer personas at once."),
+ "overloaded": ("warning", "stopped because the model API was overloaded",
+ "The API answered 529 for too long. Run it again later."),
+ "no_output": ("error", "produced no output",
+ "Claude Code wrote no result: see results/agent-errors.txt in the decrypted results."),
+ "error": ("warning", "stopped on an error",
+ "See results/agent-output.json in the decrypted results."),
+}
+
+
+def read(path):
+ try:
+ with open(path, encoding="utf-8", errors="replace") as f:
+ return f.read()
+ except OSError:
+ return ""
+
+
+def classify(output_path, errors_path):
+ """(status, details) where details has the number of turns and the cost when known."""
+ raw, errors = read(output_path).strip(), read(errors_path)
+ try:
+ data = json.loads(raw) if raw else None
+ except ValueError:
+ data = None
+ if isinstance(data, list): # some versions print every message: the result comes last
+ data = next((m for m in reversed(data) if isinstance(m, dict) and m.get("type") == "result"), None)
+ details = {}
+ if isinstance(data, dict):
+ for key in ("num_turns", "total_cost_usd"):
+ if isinstance(data.get(key), (int, float)) and not isinstance(data.get(key), bool):
+ details[key] = data[key]
+ if data.get("subtype") == "success" and not data.get("is_error"):
+ return "finished", details
+ if data.get("subtype") == "error_max_turns":
+ return "max_turns", details
+ text = ((data.get("result") or "") if isinstance(data, dict) else raw) + "\n" + errors
+ for status, pattern in PATTERNS:
+ if re.search(pattern, str(text), re.I):
+ return status, details
+ if not isinstance(data, dict):
+ return "no_output", details
+ return "error", details
+
+
+def describe(status, details):
+ parts = []
+ if "num_turns" in details:
+ parts.append(f"{details['num_turns']} turns")
+ if "total_cost_usd" in details:
+ parts.append(f"${details['total_cost_usd']:.2f}")
+ label = {"finished": "finished", "max_turns": "used all its turns"}.get(status) or PROBLEMS[status][1]
+ return label + (f" ({', '.join(parts)})" if parts else "")
+
+
+def secret_name():
+ if os.environ.get("LLM_BASE_URL"):
+ return "LLM_API_KEY"
+ if os.environ.get("ANTHROPIC_API_KEY"):
+ return "ANTHROPIC_API_KEY"
+ return "CLAUDE_CODE_OAUTH_TOKEN (token from claude setup-token)"
+
+
+def main(argv):
+ if len(argv) != 4:
+ sys.exit(__doc__)
+ persona = re.sub(r"[^\w.-]", "", argv[3]) or "agent"
+ status, details = classify(argv[1], argv[2])
+ line = f"{persona}: {describe(status, details)}"
+ if os.environ.get("GITHUB_ACTIONS") != "true":
+ print(("WARNING: " if status in PROBLEMS else "") + line)
+ return status
+ if status in PROBLEMS:
+ level, title, hint = PROBLEMS[status]
+ print(f"::{level} title={persona} {title}::{hint.format(secret=secret_name())}")
+ else:
+ print(line)
+ summary = os.environ.get("GITHUB_STEP_SUMMARY")
+ if summary:
+ with open(summary, "a", encoding="utf-8") as f:
+ f.write(f"Agent {line}\n")
+ return status
+
+
+if __name__ == "__main__":
+ main(sys.argv)
diff --git a/scripts/android/run_agent.sh b/scripts/android/run_agent.sh
index 9dbea83..dafa979 100755
--- a/scripts/android/run_agent.sh
+++ b/scripts/android/run_agent.sh
@@ -52,6 +52,7 @@ claude -p "Read $BRIEF and personas.json, then do the mission until the final re
--allowedTools "Bash(adb:*),Bash(python3 scripts/android/screen.py:*),Bash(python3 scripts/android/type.py:*),Bash(sleep:*),Bash(ls:*),Bash(cat:*),Bash(mkdir:*),Read,Write,Edit" \
> results/agent-output.json 2> results/agent-errors.txt
CODE=$?
+python3 scripts/agent_status.py results/agent-output.json results/agent-errors.txt "$PERSONA" || true
if [ -n "$REC" ]; then
touch /tmp/stop-rec; adb shell pkill -INT screenrecord; sleep 4; kill "$REC" 2>/dev/null
mkdir -p "results/$PERSONA/video"
diff --git a/scripts/collect.sh b/scripts/collect.sh
index 9830c83..6086979 100755
--- a/scripts/collect.sh
+++ b/scripts/collect.sh
@@ -13,6 +13,7 @@ for key in "$OUT"/enc/*/*.key.bin; do
pass=$(openssl pkeyutl -decrypt -inkey "$PRIV" -pkeyopt rsa_padding_mode:oaep -in "$key")
mkdir -p "$OUT/$name"
openssl enc -d -aes-256-cbc -pbkdf2 -in "$dir/$name.tgz.enc" -pass "pass:$pass" | tar xz -C "$OUT/$name"
- grep -l "hit your" "$OUT/$name"/results/agent-output.json 2>/dev/null && echo "WARNING: $name stopped on a usage limit"
+ python3 "$(dirname "$0")/agent_status.py" "$OUT/$name/results/agent-output.json" "$OUT/$name/results/agent-errors.txt" "$name" || true
done
python3 "$(dirname "$0")/summarize.py" "$OUT" > "$OUT/SUMMARY.md" && echo "Summary: $OUT/SUMMARY.md"
+echo "How did it go? Tell us what it found, or where it got in the way: https://github.com/pierridotite/mobile-agent-testers/issues/new?template=usage-feedback.yml"
diff --git a/scripts/ios/run_agent.sh b/scripts/ios/run_agent.sh
index d4f142b..1fd5178 100755
--- a/scripts/ios/run_agent.sh
+++ b/scripts/ios/run_agent.sh
@@ -35,6 +35,7 @@ claude -p "Read $BRIEF and personas.json, then do the mission until the final re
--allowedTools "Bash(bash scripts/ios/gesture.sh:*),Bash(python3 scripts/ios/screen.py:*),Bash(python3 scripts/ios/type.py:*),Bash(sleep:*),Bash(ls:*),Bash(cat:*),Bash(mkdir:*),Read,Write,Edit" \
> results/agent-output.json 2> results/agent-errors.txt
CODE=$?
+python3 scripts/agent_status.py results/agent-output.json results/agent-errors.txt "$PERSONA" || true
if [ -n "$REC" ]; then
kill -INT "$REC" 2>/dev/null
for _ in $(seq 1 30); do kill -0 "$REC" 2>/dev/null || break; sleep 1; done
diff --git a/setup.ps1 b/setup.ps1
index d84b810..04ecd3f 100644
--- a/setup.ps1
+++ b/setup.ps1
@@ -19,6 +19,9 @@ if (-not $openssl) { Write-Host "openssl not found: install Git for Windows (win
$repo = gh repo view --json nameWithOwner -q .nameWithOwner
Write-Host "Setting up agent testers for $repo"
+if ((gh repo view --json visibility -q .visibility) -eq "PRIVATE") {
+ Write-Host "Note: $repo is private. GitHub's runners are only free for public repos: here each macOS minute counts ten times against your Actions minutes."
+}
$keyDir = Join-Path $HOME ".mobile-agent-testers"
New-Item -ItemType Directory -Force -Path $keyDir | Out-Null
$priv = Join-Path $keyDir (($repo -replace "/", "_") + ".pem")
@@ -39,11 +42,16 @@ if (($secrets -notcontains "CLAUDE_CODE_OAUTH_TOKEN") -and ($secrets -notcontain
Write-Host "Claude access. Either:"
Write-Host " 1) a Claude Pro/Max subscription: run 'claude setup-token' in another terminal and paste the token"
Write-Host " 2) an Anthropic API key (pay per token)"
- $choice = Read-Host "Choose 1 or 2"
+ do { $choice = Read-Host "Choose 1 or 2" } while (($choice -ne "1") -and ($choice -ne "2"))
$name = if ($choice -eq "2") { "ANTHROPIC_API_KEY" } else { "CLAUDE_CODE_OAUTH_TOKEN" }
- $secure = Read-Host "Paste it (hidden)" -AsSecureString
- $plain = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure))
- gh secret set $name --body $plain.Trim()
+ $prefix = if ($choice -eq "2") { "sk-ant-api" } else { "sk-ant-oat" }
+ do {
+ $secure = Read-Host "Paste it (hidden)" -AsSecureString
+ $plain = ([Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure))).Trim()
+ if (-not $plain) { Write-Host "Nothing pasted, try again." }
+ } while (-not $plain)
+ if (-not $plain.StartsWith($prefix)) { Write-Host "Warning: it does not start with $prefix." }
+ gh secret set $name --body $plain
Remove-Variable plain
Write-Host "Secret $name set"
}
@@ -52,5 +60,7 @@ git add results_public.pem
git diff --cached --quiet
if ($LASTEXITCODE -ne 0) { git commit -qm "Add results public key"; git push -q; Write-Host "Public key committed and pushed" }
Write-Host ""
-Write-Host "Done. Run the demo (2 Android + 2 iOS testers on the demo app, about 30 min):"
+Write-Host "Done. Run the demo (2 Android + 2 iOS testers on the demo app, about 20 min):"
Write-Host " gh workflow run agent-testers.yml"
+Write-Host "Follow it:"
+Write-Host " gh run watch"
diff --git a/setup.sh b/setup.sh
index 4932a84..d25242e 100755
--- a/setup.sh
+++ b/setup.sh
@@ -10,6 +10,9 @@ command -v openssl >/dev/null || { echo "openssl is required"; exit 1; }
gh auth status >/dev/null 2>&1 || { echo "Run: gh auth login"; exit 1; }
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
echo "Setting up agent testers for $REPO"
+if [ "$(gh repo view --json visibility -q .visibility 2>/dev/null)" = PRIVATE ]; then
+ echo "Note: $REPO is private. GitHub's runners are only free for public repos: here each macOS minute counts ten times against your Actions minutes."
+fi
KEYDIR="$HOME/.mobile-agent-testers"; mkdir -p "$KEYDIR"; chmod 700 "$KEYDIR"
PRIV="$KEYDIR/${REPO//\//_}.pem"
@@ -30,9 +33,28 @@ if ! grep -qxE 'CLAUDE_CODE_OAUTH_TOKEN|ANTHROPIC_API_KEY' <<<"$SECRETS"; then
echo "Claude access. Either:"
echo " 1) a Claude Pro/Max subscription: run 'claude setup-token' in another terminal and paste the token"
echo " 2) an Anthropic API key (pay per token)"
- read -rp "Choose 1 or 2: " CHOICE
- NAME=$([ "$CHOICE" = 2 ] && echo ANTHROPIC_API_KEY || echo CLAUDE_CODE_OAUTH_TOKEN)
- read -rsp "Paste it (hidden): " VALUE; echo
+ CHOICE=""
+ while [ "$CHOICE" != 1 ] && [ "$CHOICE" != 2 ]; do read -rp "Choose 1 or 2: " CHOICE; done
+ if [ "$CHOICE" = 1 ]; then
+ NAME=CLAUDE_CODE_OAUTH_TOKEN PREFIX=sk-ant-oat KIND="token from claude setup-token"
+ command -v claude >/dev/null || echo "Claude Code is not installed here: npm install -g @anthropic-ai/claude-code, then claude setup-token"
+ else
+ NAME=ANTHROPIC_API_KEY PREFIX=sk-ant-api KIND="Anthropic API key"
+ fi
+ while :; do
+ read -rsp "Paste it (hidden): " VALUE; echo
+ VALUE=$(printf '%s' "$VALUE" | tr -d '[:space:]')
+ if [ -z "$VALUE" ]; then echo "Nothing pasted, try again."; continue; fi
+ case "$VALUE" in "$PREFIX"*) ;; *) echo "Warning: it does not start with $PREFIX, like a $KIND does." ;; esac
+ if [ "$CHOICE" = 2 ] && command -v curl >/dev/null; then
+ # free endpoint, no tokens used; the key goes through stdin, not the command line
+ STATUS=$(printf 'x-api-key: %s\nanthropic-version: 2023-06-01\n' "$VALUE" |
+ curl -s -m 15 -o /dev/null -w '%{http_code}' -H @- https://api.anthropic.com/v1/models || true)
+ if [ "$STATUS" = 401 ] || [ "$STATUS" = 403 ]; then echo "Anthropic refused this key ($STATUS): paste another one."; continue; fi
+ [ "$STATUS" = 200 ] && echo "Key checked with Anthropic."
+ fi
+ break
+ done
printf '%s' "$VALUE" | gh secret set "$NAME"
unset VALUE
echo "Secret $NAME set"
@@ -44,8 +66,10 @@ if ! git diff --quiet -- results_public.pem 2>/dev/null || ! git ls-files --erro
fi
cat <<MSG
-Done. Run the demo (2 Android + 2 iOS testers on the demo app, about 30 min):
+Done. Run the demo (2 Android + 2 iOS testers on the demo app, about 20 min):
gh workflow run agent-testers.yml
+Follow it:
+ gh run watch
Then download and decrypt the reports:
bash scripts/collect.sh \$(gh run list --workflow agent-testers.yml -L 1 --json databaseId -q '.[0].databaseId')
MSG
diff --git a/tests/test_agent_status.py b/tests/test_agent_status.py
new file mode 100644
index 0000000..a973df9
--- /dev/null
+++ b/tests/test_agent_status.py
@@ -0,0 +1,130 @@
+"""scripts/agent_status.py: how an agent's run ended, without leaking what it wrote."""
+import json
+import os
+import subprocess
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent.parent
+sys.path.insert(0, str(ROOT / "scripts"))
+import agent_status # noqa: E402
+
+SECRET_TEXT = "Settings: the device name is cut to 'Secret C...'"
+
+
+class Classify(unittest.TestCase):
+ def setUp(self):
+ self.dir = Path(tempfile.mkdtemp())
+ self.out, self.err = self.dir / "agent-output.json", self.dir / "agent-errors.txt"
+
+ def status(self, output=None, errors=""):
+ if output is not None:
+ self.out.write_text(output if isinstance(output, str) else json.dumps(output), encoding="utf-8")
+ self.err.write_text(errors, encoding="utf-8")
+ return agent_status.classify(self.out, self.err)
+
+ def test_finished_with_turns_and_cost(self):
+ status, details = self.status({"type": "result", "subtype": "success", "is_error": False,
+ "num_turns": 37, "total_cost_usd": 0.312, "result": SECRET_TEXT})
+ self.assertEqual(status, "finished")
+ self.assertEqual(details, {"num_turns": 37, "total_cost_usd": 0.312})
+ self.assertEqual(agent_status.describe(status, details), "finished (37 turns, $0.31)")
+
+ def test_out_of_turns(self):
+ self.assertEqual(self.status({"subtype": "error_max_turns", "num_turns": 400})[0], "max_turns")
+
+ def test_usage_limits(self):
+ for text in ("You've hit your 5-hour limit", "You've hit your limit · resets 3pm (UTC)",
+ "Claude AI usage limit reached|1763900000", "You've hit your weekly limit"):
+ with self.subTest(text=text):
+ self.assertEqual(self.status({"subtype": "success", "is_error": True, "result": text})[0],
+ "usage_limit")
+
+ def test_refused_token_from_stderr_only(self):
+ self.assertEqual(self.status("", "Invalid API key · Please run /login\n")[0], "auth")
+ self.assertEqual(self.status("", 'API Error: 401 {"type":"error","error":{"type":"authentication_error"}}')[0],
+ "auth")
+
+ def test_credit_rate_limit_overloaded(self):
+ def result(text):
+ return {"subtype": "success", "is_error": True, "result": text}
+ self.assertEqual(self.status(result("Credit balance is too low"))[0], "credit")
+ self.assertEqual(self.status(result('API Error: 429 {"type":"rate_limit_error"}'))[0], "rate_limit")
+ self.assertEqual(self.status(result('API Error: 529 {"type":"overloaded_error"}'))[0], "overloaded")
+
+ def test_no_output(self):
+ self.assertEqual(self.status(None)[0], "no_output")
+ self.assertEqual(self.status("", "")[0], "no_output")
+ self.assertEqual(self.status("not json", "")[0], "no_output")
+
+ def test_other_error(self):
+ self.assertEqual(self.status({"subtype": "error_during_execution", "is_error": True})[0], "error")
+
+ def test_message_list_output(self):
+ msgs = [{"type": "system"}, {"type": "assistant"},
+ {"type": "result", "subtype": "success", "is_error": False, "num_turns": 3}]
+ self.assertEqual(self.status(msgs)[0], "finished")
+
+ def test_text_inside_a_finished_report_is_ignored(self):
+ # an app screen that says "usage limit" must not turn a finished run into a failure
+ self.assertEqual(self.status({"subtype": "success", "is_error": False,
+ "result": "The quota screen says usage limit reached"})[0], "finished")
+
+
+class Output(unittest.TestCase):
+ def run_script(self, output, errors="", env=None):
+ d = Path(tempfile.mkdtemp())
+ (d / "o.json").write_text(json.dumps(output), encoding="utf-8")
+ (d / "e.txt").write_text(errors, encoding="utf-8")
+ summary = d / "summary.md"
+ full_env = {k: v for k, v in os.environ.items()
+ if k not in ("GITHUB_ACTIONS", "LLM_BASE_URL", "ANTHROPIC_API_KEY")}
+ full_env.update(env or {})
+ if full_env.get("GITHUB_ACTIONS") == "true":
+ full_env["GITHUB_STEP_SUMMARY"] = str(summary)
+ proc = subprocess.run([sys.executable, str(ROOT / "scripts" / "agent_status.py"),
+ str(d / "o.json"), str(d / "e.txt"), "anna"],
+ capture_output=True, text=True, env=full_env, check=True)
+ return proc.stdout, summary.read_text(encoding="utf-8") if summary.exists() else ""
+
+ def test_actions_annotation_and_summary_without_the_report(self):
+ out, summary = self.run_script({"subtype": "success", "is_error": True,
+ "result": "You've hit your 5-hour limit. " + SECRET_TEXT},
+ env={"GITHUB_ACTIONS": "true"})
+ self.assertTrue(out.startswith("::warning title=anna stopped on a Claude usage limit::"), out)
+ self.assertIn("anna: stopped on a Claude usage limit", summary)
+ self.assertNotIn("Secret", out + summary)
+
+ def test_finished_run_prints_no_report_text(self):
+ out, summary = self.run_script({"subtype": "success", "is_error": False, "num_turns": 12,
+ "result": SECRET_TEXT}, env={"GITHUB_ACTIONS": "true"})
+ self.assertEqual(out.strip(), "anna: finished (12 turns)")
+ self.assertNotIn("Secret", out + summary)
+
+ def test_auth_hint_names_the_secret_in_use(self):
+ out, _ = self.run_script({"subtype": "success", "is_error": True, "result": "Invalid API key"},
+ env={"GITHUB_ACTIONS": "true", "LLM_BASE_URL": "https://openrouter.ai/api"})
+ self.assertIn("::error title=anna could not sign in to the model API::", out)
+ self.assertIn("gh secret set LLM_API_KEY", out)
+
+ def test_plain_line_on_your_machine(self):
+ out, _ = self.run_script({"subtype": "success", "is_error": True, "result": "Credit balance is too low"})
+ self.assertEqual(out.strip(), "WARNING: anna: found no API credit")
+
+ def test_annotation_titles_have_no_reserved_characters(self):
+ for level, title, _ in agent_status.PROBLEMS.values():
+ self.assertIn(level, ("warning", "error"))
+ self.assertNotRegex(title, "[:,%\n]")
+
+
+class Wiring(unittest.TestCase):
+ def test_both_platforms_and_collect_call_it(self):
+ for f in ("scripts/ios/run_agent.sh", "scripts/android/run_agent.sh", "scripts/collect.sh"):
+ with self.subTest(f=f):
+ self.assertIn("agent_status.py", (ROOT / f).read_text(encoding="utf-8"))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_setup.py b/tests/test_setup.py
new file mode 100644
index 0000000..d3c7097
--- /dev/null
+++ b/tests/test_setup.py
@@ -0,0 +1,79 @@
+"""setup.sh, offline: stand-ins for gh, git and curl, answers typed on stdin."""
+import os
+import shutil
+import subprocess
+import tempfile
+import unittest
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent.parent
+FAKE_GH = """#!/usr/bin/env bash
+case "$*" in
+ "auth status") exit 0 ;;
+ "repo view --json nameWithOwner -q .nameWithOwner") echo "someone/testers" ;;
+ "repo view --json visibility -q .visibility") echo "$FAKE_VISIBILITY" ;;
+ "secret list --json name -q .[].name") echo "ARTIFACT_PASSPHRASE" ;;
+ "secret set "*) cat > "$FAKE_SECRETS/$3" ;;
+ *) echo "unexpected gh call: $*" >&2; exit 1 ;;
+esac
+"""
+FAKE_GIT = "#!/usr/bin/env bash\nexit 0\n" # public key already committed
+# Anthropic answers 401 to a key containing "bad", 200 otherwise; logs its arguments
+FAKE_CURL = """#!/usr/bin/env bash
+echo "$*" >> "$FAKE_SECRETS/curl-args"
+if grep -q bad; then printf 401; else printf 200; fi
+"""
+
+
+class Setup(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ cls.home = Path(tempfile.mkdtemp())
+ keys = cls.home / ".mobile-agent-testers"
+ keys.mkdir()
+ subprocess.run(["openssl", "genpkey", "-algorithm", "RSA", "-pkeyopt", "rsa_keygen_bits:2048",
+ "-out", str(keys / "someone_testers.pem")], check=True, capture_output=True)
+
+ def run_setup(self, answers, visibility="PUBLIC"):
+ work = Path(tempfile.mkdtemp())
+ bin_dir, secrets = work / "bin", work / "secrets"
+ bin_dir.mkdir()
+ secrets.mkdir()
+ for name, body in (("gh", FAKE_GH), ("git", FAKE_GIT), ("curl", FAKE_CURL)):
+ (bin_dir / name).write_text(body)
+ (bin_dir / name).chmod(0o755)
+ shutil.copy(ROOT / "setup.sh", work / "setup.sh")
+ env = {"PATH": f"{bin_dir}:{os.environ['PATH']}", "HOME": str(self.home),
+ "FAKE_SECRETS": str(secrets), "FAKE_VISIBILITY": visibility}
+ proc = subprocess.run(["bash", "setup.sh"], cwd=work, input=answers, capture_output=True,
+ text=True, env=env)
+ return proc, secrets
+
+ def test_subscription_token_after_a_wrong_choice_and_an_empty_paste(self):
+ proc, secrets = self.run_setup("5\n1\n\n sk-ant-oat01-abc \n")
+ self.assertEqual(proc.returncode, 0, proc.stderr)
+ self.assertEqual((secrets / "CLAUDE_CODE_OAUTH_TOKEN").read_text(), "sk-ant-oat01-abc")
+ self.assertIn("Nothing pasted", proc.stdout)
+ self.assertNotIn("Warning", proc.stdout)
+ self.assertFalse((secrets / "curl-args").exists()) # tokens are not checked online
+ self.assertIn("about 20 min", proc.stdout)
+ self.assertIn("gh run watch", proc.stdout)
+
+ def test_api_key_refused_then_accepted_never_on_the_command_line(self):
+ proc, secrets = self.run_setup("2\nsk-ant-api03-bad\nsk-ant-api03-good\n")
+ self.assertEqual(proc.returncode, 0, proc.stderr)
+ self.assertEqual((secrets / "ANTHROPIC_API_KEY").read_text(), "sk-ant-api03-good")
+ self.assertIn("Anthropic refused this key (401)", proc.stdout)
+ self.assertIn("Key checked with Anthropic", proc.stdout)
+ self.assertNotIn("sk-ant", (secrets / "curl-args").read_text())
+
+ def test_warns_about_an_unexpected_prefix_and_a_private_repo(self):
+ proc, secrets = self.run_setup("1\nsomething-else\n", visibility="PRIVATE")
+ self.assertEqual(proc.returncode, 0, proc.stderr)
+ self.assertIn("does not start with sk-ant-oat", proc.stdout)
+ self.assertIn("someone/testers is private", proc.stdout)
+ self.assertEqual((secrets / "CLAUDE_CODE_OAUTH_TOKEN").read_text(), "something-else")
+
+
+if __name__ == "__main__":
+ unittest.main()