From 45da78d645037614c5d3e65bc5a700917bd2a5fc Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Mon, 14 Sep 2026 17:00:17 -0700 Subject: [PATCH] test(computer-use): element click carries the token from the live schema alone Invariant through the real click() path on the modern tools/list shape (no capabilities[] array, element_token only in inputSchema); red on main. --- tests/tools/test_computer_use.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/tools/test_computer_use.py b/tests/tools/test_computer_use.py index 65dce0aead..737a503f51 100644 --- a/tests/tools/test_computer_use.py +++ b/tests/tools/test_computer_use.py @@ -2228,6 +2228,17 @@ class TestElementTokenAttachment: # The matching token rode along — cua-driver will prefer it. assert args["element_token"] == "s0001:5" + def test_token_attached_when_only_input_schema_advertises_it(self): + """cua-driver >= 0.21 dropped the per-tool `capabilities[]` array from tools/list but advertises + `element_token` in `click`'s inputSchema and REFUSES a bare element_index (`snapshot_id_required`). + The token must ride along from the live schema alone, or every element click is refused.""" + backend = self._backend_with_session({}) # no capabilities[] at all — the modern shape + backend._session.supports_input_property = lambda tool, prop: (tool, prop) == ("click", "element_token") + backend._snapshot_tokens = {5: "s00000001:5"} + backend.click(element=5, button="left") + _, args = backend._session.call_tool.call_args.args + assert args["element_token"] == "s00000001:5" + def test_capture_refreshes_snapshot_tokens(self): """A fresh capture should overwrite any stale tokens from a