Skip to main content

strands-xa11y

Drive native desktop applications from a Strands agent — through the operating system's accessibility tree, not screenshots.

Accessibility APIs are the most robust way to control a desktop — they expose the same structured tree of roles, names, and states that assistive technology uses — and this library drives them with Playwright-style selectors, so targets survive a UI that moves, restyles, or re-renders between turns. Built on xa11y, which speaks AXUIElement on macOS, UI Automation on Windows, and AT-SPI2 on Linux behind one API.

from strands import Agent
from strands_xa11y import use_desktop

agent = Agent(tools=[use_desktop])
agent("Open TextEdit, type 'hello' into the document, and save it as notes.txt")

Why not screenshots

A screenshot-and-OCR loop has to infer what is on screen and then guess where to click. The accessibility tree already knows.

screenshot + OCR strands-xa11y
Targeting coordinates inferred from pixels selectors and refs resolved against the real UI tree
State invisible — "is this button disabled?" is a guess enabled, checked, focused, expanded, selected read directly
Cost per turn a full image a few hundred lines of text
Failure mode silently clicks the wrong thing names what it was waiting for, what it saw, and near-miss elements
Setup Tesseract, OpenCV, numpy one wheel

Pixels are still there when you need them — canvases, video, rendering bugs — as an explicit fallback rather than the default.

Install

pip install strands-xa11y

Prebuilt wheels cover macOS, Windows, and Linux; Python 3.10+.

Permissions

This is where first runs fail, so check here first.

  • macOS — grant Accessibility to whatever hosts the agent (System Settings › Privacy & Security › Accessibility). Screenshots additionally need Screen & System Audio Recording. Restart the process after granting.
  • Linux — AT-SPI2 must be running (standard on GNOME). Chromium and Electron apps only publish a tree when launched with --force-renderer-accessibility. On Wayland, synthesised input needs /dev/uinput, which means membership of the input group.
  • Windows — nothing to grant. If a target app runs elevated, the agent has to as well.

The loop

1. Snapshot. Each line is one node, with a ref.

use_desktop({"action": {"type": "snapshot", "app": "TextEdit"}})
TextEdit (pid 4242)
e1 application "TextEdit"
  e2 window "Untitled" [active]
    e3 toolbar
      e4 button "Bold"
      e5 button "Italic" [disabled]
    e7 group
      e8 text_field "File name" value="untitled"
      e9 check_box "Wrap lines" [unchecked]
    e10 text_area "document" value="Dear Alice,"

2. Act on refs.

use_desktop({"action": {"type": "click", "target": {"ref": "e4"}}})
use_desktop({"action": {"type": "type", "target": {"ref": "e8"}, "text": "notes.txt", "replace": True}})
use_desktop({"action": {"type": "act", "target": {"ref": "e9"}, "verb": "check"}})

3. Re-snapshot after the UI changes. Refs are never reused, so a stale one fails loudly instead of hitting whatever moved into its place.

Refs re-resolve through the platform's stable_id where one exists, otherwise through a structural selector path, and only fall back to a captured handle as a last resort — so the first two paths auto-wait and survive a re-render.

You can skip refs and address elements directly with xa11y selectors:

use_desktop({"action": {"type": "click", "target": {"app": "TextEdit", "selector": "button[name='Save']"}}})

Actions

Perceivelist_apps, snapshot, find, read, wait

Act, through the accessibility layerclick, type, focus, and act for the rest: toggle, check, uncheck, select, expand, collapse, increment, decrement, set_number, select_text, show_menu, scroll_into_view, blur, and raw as an escape hatch to any platform action name.

Fall back to synthesised input and pixelskey, mouse, drag, scroll, screenshot

Lifecycleopen_app (waits for the app to register with the accessibility bridge rather than sleeping), close_app (needs pip install 'strands-xa11y[process]')

Every action is a separate variant in a discriminated union, so the model is shown exactly the fields that action takes.

Read-only agents

inspect_desktop is the same tool with the acting half removed — list_apps, snapshot, find, read, wait, screenshot. Give an agent that one alone when it should observe but never touch.

from strands_xa11y import inspect_desktop

agent = Agent(tools=[inspect_desktop])

The restriction is in the schema, not a runtime check, so there is no acting action for the model to reach for.

Consent and privacy

Anything that changes the machine — clicking, typing, launching, terminating — asks for confirmation on the terminal first. Set BYPASS_TOOL_CONSENT=true to hand approval to your agent runtime instead, which is what you want when the runtime has its own approval UX or when running unattended. With no terminal to ask on and no bypass set, the action is refused rather than assumed.

Reading the tree never prompts. screenshot prompts when the capture leaves the process — send_image=true puts whatever is on the user's screen into the transcript, and save_path writes it to disk. Screenshots are withheld from the model by default, and images over 5MB are dropped rather than sent.

close_app terminates every process whose name contains the string you give it, so it takes the most specific name you have and never signals the process hosting the agent.

Errors are meant to be read

xa11y reports what a failed call was waiting for, what it last observed, and which elements nearly matched. That gets passed through verbatim:

TimeoutError: timed out
  condition: visible
  selector: button[name='Sav']
  last observed: selector never matched
  near misses: button 'Save'; button 'Save As…'

Usually enough for the model to fix its own selector without falling back to pixels.

Known limits

  • scroll_into_view is a no-op on macOS (no accessibility equivalent) — use scroll.
  • blur only works on macOS.
  • The * selector materialises every element's attributes; it is cheap on Windows, expensive on macOS and Linux.
  • detail="rich" snapshots read each property individually, which is one D-Bus round trip apiece on Linux. Use detail="basic" on large trees, or scope with selector.
  • Snapshots are bounded by max_depth and max_nodes and are filtered to interactive nodes by default. Truncation is always reported.

Development

pip install hatch
hatch run prepare   # format, lint, typecheck, test
hatch run cov       # the same tests, with a coverage report

Tests run against a fake accessibility backend — including a small selector evaluator — so they need no display, no bus, and no windows. The suite covers every statement in src/, and CI fails below that, so a new branch arrives with the test that exercises it.

CI runs the suite on Python 3.10–3.13, checks formatting, lint, and types, builds the wheel, and imports the package on macOS, Windows, and Linux to prove both tool schemas build everywhere the package claims to run. A weekly canary re-runs it against the latest strands-agents and xa11y so SDK drift breaks here before it breaks anyone's install.

License

MIT. Built on xa11y, also MIT.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strands_xa11y-0.1.0.tar.gz (49.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strands_xa11y-0.1.0-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

Details for the file strands_xa11y-0.1.0.tar.gz.

File metadata

  • Download URL: strands_xa11y-0.1.0.tar.gz
  • Upload date:
  • Size: 49.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for strands_xa11y-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57fb3bf4b21ad0243b949b893d849aa3e0e384cfd45efd5d6744faff5887501d
MD5 1643dd79843b97b4b67ebbaa91dbbf92
BLAKE2b-256 1373b9f55483d49d070bf2abdf067947cdc5064a20d2c1824d837cfc246bc320

See more details on using hashes here.

Provenance

The following attestation bundles were made for strands_xa11y-0.1.0.tar.gz:

Publisher: publish.yml on xa11y/strands-xa11y

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file strands_xa11y-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: strands_xa11y-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for strands_xa11y-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ee87e282fd87b3605a2b1651ddd4872a1a7fd8e6f481947dffba950f1adae53
MD5 3f4dde8cd7e13182a5d153fb46491e08
BLAKE2b-256 6110855a277029935494e42fd61ce126f1c8c6f7dddc2659e12ed91c2908a2e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for strands_xa11y-0.1.0-py3-none-any.whl:

Publisher: publish.yml on xa11y/strands-xa11y

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page