Repository navigation
feat(android): give agents a compact UI tree - #395
Merged
Merged
Conversation
android_get_ui_tree now returns a compact tree by default. It keeps nodes with text, a content description, a resource id or an action, and their hierarchy. Bounds stay in pixels and the result reports screen density. Output has a maxChars limit and says when it truncates. raw=true returns the XML. Fixtures come from Settings, Flutter and Compose on an emulator. Closes #351
# Conflicts: # docs/releases/UNRELEASED.md
2 tasks
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
android_get_ui_treereturned the rawuiautomator dumpXML. A busy screen cost thousands of tokens, and most nodes held nothing an agent could read or act on, so agents skipped the tree and guessed from screenshots.The tool now returns a compact tree by default. It keeps the hierarchy, actionable ancestors and every node with text, a label or a resource id, with pixel bounds, the screen density and an explicit size limit that says when it cuts. Raw XML stays available with
raw: true. Labels are redacted as whole values before they are cut or quoted.Proof: fixtures from Android Settings, a Flutter app and a Compose app on a real emulator keep their labels and hierarchy, and a live tap at a compact bounds centre hit the right button. The full suite passes (3364 tests).
Sol review: round 1 found two redaction-order leaks (blockers), round 2 approved. The regex nit on malformed XML stays open as non-blocking.
Closes #351
Tokens before and after (old MCP JSON body against the new summary plus tree text):
~/.pickforge/investigations/351/agent-device/packages/android/test/ui-tree.test.ts,packages/mcp-server/test/android.test.tsraw: true~/.pickforge/investigations/351/maxChars1000; MCP test rejectsmaxChars10 before any adb calltruncated: truein JSONempty: truewith a reason~/.pickforge/investigations/351/token-table.md,tok/measure.tsredactSecrets~/.pickforge/investigations/qa-351-231/Follow-ups: #384 (compact tree in the CLI), #385 (password flags in raw XML redaction), #386 (launch-app on a sleeping screen), #387 (Compose role folding).