File size: 22,683 Bytes
9c73a22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
---
license: gemma
base_model: unsloth/functiongemma-270m-it
library_name: transformers
pipeline_tag: text-generation
language:
- en
tags:
- function-calling
- tool-use
- mobile-automation
- android
- gemma
- unsloth
- agent
---

# FunctionGemma-270M — Mobile Actions

A fine-tune of [`unsloth/functiongemma-270m-it`](https://huggingface.co/unsloth/functiongemma-270m-it)
that turns a natural-language instruction into a **single, validated mobile-action tool call**.
It targets two uses:

- **Mobile test automation** — drive an Appium / UiAutomator / Espresso / XCUITest layer from plain-English steps.
- **Agentic workflows** — let an on-device agent pick the next action as a structured, executable call.

At 270M parameters it runs on CPU, a modest GPU, or fully on-device (LiteRT-LM / Google AI Edge).

## Repository layout

| Path | Contents |
| --- | --- |
| `merged_16bit/` | Standalone 16-bit model (load this for inference) |
| `lora/` | LoRA adapter only (apply on top of the base model) |

## Output format

The model emits FunctionGemma's call DSL, e.g.:

```
<start_function_call>call:tap{selector:<escape>login_button<escape>}<end_function_call>
```

Parse it with:

```python
import re
CALL = re.compile(r"<start_function_call>call:(\w+)\{(.*?)\}<end_function_call>", re.DOTALL)
ARG  = re.compile(r"(\w+):(?:<escape>(.*?)<escape>|([^,}]*))")

def parse(text):
    out = []
    for name, raw in CALL.findall(text):
        args = {k: (e or p).strip() for k, e, p in ARG.findall(raw)}
        out.append({"name": name, "arguments": args})
    return out
```

## Usage

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

REPO = "ahmadw/functiongemma-270m-mobile"
tok = AutoTokenizer.from_pretrained(REPO, subfolder="merged_16bit")
model = AutoModelForCausalLM.from_pretrained(REPO, subfolder="merged_16bit").eval()

prompt = tok.apply_chat_template(
    [{"role": "user", "content": "Tap the login button."}],
    tools=TOOLS,                 # the schema below
    tokenize=False, add_generation_prompt=True,
).removeprefix("<bos>")

inputs = tok(prompt, return_tensors="pt")
with torch.no_grad():
    out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
# -> <start_function_call>call:tap{selector:<escape>login_button<escape>}<end_function_call>
```

You **must** pass the `tools` schema (below) so the chat template declares the available actions.

### Reliable tool calls (recommended)

For production, constrain decoding so the model can only emit a syntactically valid call naming one
of your tools (prevents hallucinated names). Pair the model with
[`xgrammar`](https://pypi.org/project/xgrammar/) — build an EBNF grammar whose function name is
restricted to your tool list, pass it as a `LogitsProcessor` to `generate(...)`, and snap any
out-of-schema name to the nearest valid tool as a dependency-free fallback.

### Wiring into an automation driver

The model decides *what*; your driver decides *how*. Map each tool name to a concrete action:

```python
HANDLERS = {
    "launch_app": lambda d, app_name:       d.activate_app(app_name),
    "tap":        lambda d, selector:       d.find(selector).click(),
    "type_text":  lambda d, selector, text: d.find(selector).send_keys(text),
    "swipe":      lambda d, direction:      d.swipe(direction),
    "wait":       lambda d, duration_ms:    d.sleep(duration_ms / 1000),
    # ... one entry per tool ...
}
```

> Selectors come from the live UI. The model infers a *reasonable* id (e.g. `login_button`) from
> the wording; resolve it against the real accessibility tree, or pass the available element ids in
> the instruction so the model can pick an exact match.

## Supported actions (38 tools)

| Category | Tools |
| --- | --- |
| App lifecycle | `launch_app`, `close_app` |
| Touch | `tap`, `double_tap`, `long_press`, `tap_coordinates`, `drag`, `swipe`, `pinch`, `scroll_to`, `pull_to_refresh` |
| Text input | `type_text`, `clear_text`, `paste_text`, `copy_text`, `dismiss_keyboard` |
| Controls | `toggle_switch`, `set_checkbox`, `select_option`, `set_slider`, `set_date`, `set_time`, `set_volume` |
| Navigation | `navigate_back`, `go_home`, `open_app_switcher`, `open_notifications`, `open_quick_settings`, `press_keyboard_key`, `rotate_screen` |
| Synchronization | `wait`, `wait_for_element` |
| Assertions | `assert_element_visible`, `assert_element_not_visible`, `assert_text_equals`, `assert_text_contains` |
| Utility | `take_screenshot`, `open_url` |

<details>
<summary>Full tool schema (copy into <code>TOOLS</code>)</summary>

```json
[
  {
    "type": "function",
    "function": {
      "name": "launch_app",
      "description": "Launch a mobile application by its visible name.",
      "parameters": {
        "type": "object",
        "properties": {
          "app_name": {
            "type": "string",
            "description": "Visible name of the app to open."
          }
        },
        "required": [
          "app_name"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "close_app",
      "description": "Close or force stop a running application.",
      "parameters": {
        "type": "object",
        "properties": {
          "app_name": {
            "type": "string",
            "description": "Visible name of the app to close."
          }
        },
        "required": [
          "app_name"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "tap",
      "description": "Tap a single UI element once by its selector. Use tap_coordinates for raw screen pixels.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id or label of the element."
          }
        },
        "required": [
          "selector"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "double_tap",
      "description": "Double tap a UI element.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id or label of the element."
          }
        },
        "required": [
          "selector"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "long_press",
      "description": "Press and hold a UI element.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id or label of the element."
          }
        },
        "required": [
          "selector"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "tap_coordinates",
      "description": "Tap the screen at absolute pixel x/y coordinates, with no element selector.",
      "parameters": {
        "type": "object",
        "properties": {
          "x": {
            "type": "integer",
            "description": "Horizontal pixel coordinate."
          },
          "y": {
            "type": "integer",
            "description": "Vertical pixel coordinate."
          }
        },
        "required": [
          "x",
          "y"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "drag",
      "description": "Drag one element onto another.",
      "parameters": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "description": "Logical id of the element to drag."
          },
          "target": {
            "type": "string",
            "description": "Logical id of the drop target."
          }
        },
        "required": [
          "source",
          "target"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "swipe",
      "description": "Swipe across the screen in a direction.",
      "parameters": {
        "type": "object",
        "properties": {
          "direction": {
            "type": "string",
            "description": "One of: up, down, left, right."
          }
        },
        "required": [
          "direction"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "pinch",
      "description": "Pinch with two fingers to zoom in or out on an element. Does not rotate the screen.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the element to zoom."
          },
          "direction": {
            "type": "string",
            "description": "Zoom direction: in or out."
          }
        },
        "required": [
          "selector",
          "direction"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "scroll_to",
      "description": "Scroll until an element becomes visible.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the target element."
          }
        },
        "required": [
          "selector"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "pull_to_refresh",
      "description": "Pull down from the top to refresh the screen.",
      "parameters": {
        "type": "object",
        "properties": {},
        "required": []
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "type_text",
      "description": "Type text into an input field.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the input field."
          },
          "text": {
            "type": "string",
            "description": "Text to enter into the field."
          }
        },
        "required": [
          "selector",
          "text"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "clear_text",
      "description": "Clear the contents of an input field.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the input field."
          }
        },
        "required": [
          "selector"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "paste_text",
      "description": "Paste the clipboard contents into an input field.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the input field."
          }
        },
        "required": [
          "selector"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "copy_text",
      "description": "Copy the text of an element to the clipboard.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the element to copy from."
          }
        },
        "required": [
          "selector"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "dismiss_keyboard",
      "description": "Hide the on-screen keyboard.",
      "parameters": {
        "type": "object",
        "properties": {},
        "required": []
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "toggle_switch",
      "description": "Set a toggle or switch to a desired state.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the switch."
          },
          "state": {
            "type": "string",
            "description": "Desired state: on or off."
          }
        },
        "required": [
          "selector",
          "state"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "set_checkbox",
      "description": "Check or uncheck a checkbox.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the checkbox."
          },
          "state": {
            "type": "string",
            "description": "Desired state: checked or unchecked."
          }
        },
        "required": [
          "selector",
          "state"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "select_option",
      "description": "Select an option from a dropdown or picker.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the dropdown."
          },
          "option": {
            "type": "string",
            "description": "Visible option to select."
          }
        },
        "required": [
          "selector",
          "option"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "set_slider",
      "description": "Set a slider to a numeric value.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the slider."
          },
          "value": {
            "type": "integer",
            "description": "Target value for the slider."
          }
        },
        "required": [
          "selector",
          "value"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "set_date",
      "description": "Set a date picker to a specific date.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the date field."
          },
          "date": {
            "type": "string",
            "description": "Date in YYYY-MM-DD format."
          }
        },
        "required": [
          "selector",
          "date"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "set_time",
      "description": "Set a time picker to a specific time.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the time field."
          },
          "time": {
            "type": "string",
            "description": "Time in HH:MM 24-hour format."
          }
        },
        "required": [
          "selector",
          "time"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "navigate_back",
      "description": "Go back one step to the previous screen. Does not return to the home screen.",
      "parameters": {
        "type": "object",
        "properties": {},
        "required": []
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "go_home",
      "description": "Return to the device home screen (launcher). This is not a single back step.",
      "parameters": {
        "type": "object",
        "properties": {},
        "required": []
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "open_app_switcher",
      "description": "Open the recent apps or app switcher.",
      "parameters": {
        "type": "object",
        "properties": {},
        "required": []
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "press_keyboard_key",
      "description": "Press a soft keyboard action key.",
      "parameters": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "One of: enter, search, done, next, go."
          }
        },
        "required": [
          "key"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "open_notifications",
      "description": "Open the notifications panel.",
      "parameters": {
        "type": "object",
        "properties": {},
        "required": []
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "open_quick_settings",
      "description": "Open the quick toggles or control panel.",
      "parameters": {
        "type": "object",
        "properties": {},
        "required": []
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "rotate_screen",
      "description": "Rotate the screen orientation between portrait and landscape. Does not zoom.",
      "parameters": {
        "type": "object",
        "properties": {
          "orientation": {
            "type": "string",
            "description": "Orientation: portrait or landscape."
          }
        },
        "required": [
          "orientation"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "set_volume",
      "description": "Set the media volume to a level.",
      "parameters": {
        "type": "object",
        "properties": {
          "level": {
            "type": "integer",
            "description": "Volume level from 0 to 100."
          }
        },
        "required": [
          "level"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "wait_for_element",
      "description": "Wait until a specific element appears, up to a timeout. Requires an element selector.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the element."
          },
          "timeout_ms": {
            "type": "integer",
            "description": "Maximum wait time in milliseconds."
          }
        },
        "required": [
          "selector",
          "timeout_ms"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "wait",
      "description": "Pause execution for a fixed duration in milliseconds. Does not wait for any element.",
      "parameters": {
        "type": "object",
        "properties": {
          "duration_ms": {
            "type": "integer",
            "description": "Duration to wait in milliseconds."
          }
        },
        "required": [
          "duration_ms"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "assert_element_visible",
      "description": "Assert that an element is visible on screen.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the element."
          }
        },
        "required": [
          "selector"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "assert_element_not_visible",
      "description": "Assert that an element is not visible on screen.",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the element."
          }
        },
        "required": [
          "selector"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "assert_text_equals",
      "description": "Assert that an element's text exactly equals an expected value (full match).",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the element."
          },
          "expected_text": {
            "type": "string",
            "description": "Expected text content."
          }
        },
        "required": [
          "selector",
          "expected_text"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "assert_text_contains",
      "description": "Assert that an element's text contains a substring (partial match).",
      "parameters": {
        "type": "object",
        "properties": {
          "selector": {
            "type": "string",
            "description": "Logical id of the element."
          },
          "text": {
            "type": "string",
            "description": "Substring expected within the element text."
          }
        },
        "required": [
          "selector",
          "text"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "take_screenshot",
      "description": "Capture a screenshot of the current screen.",
      "parameters": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "File name for the screenshot."
          }
        },
        "required": [
          "name"
        ]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "open_url",
      "description": "Open a URL in the default browser.",
      "parameters": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "Fully qualified URL to open."
          }
        },
        "required": [
          "url"
        ]
      }
    }
  }
]
```

</details>

## Evaluation

Greedy + grammar-constrained decoding, on held-out paraphrase sets the model never saw in training:

| Set | Tool selection | Exact match (name + args) |
| --- | --- | --- |
| Wild (colloquial paraphrases) | 97.7% | 90.7% |
| Stress (high-variance, 64 cases) | 93.8% | 92.2% |

Hallucinated tool names: 0. Remaining misses cluster on indirect phrasings with no action keyword
(e.g. "make the picture smaller" -> `pinch` out). Accuracy is highest when the instruction names the action.

## Training

- Base: `unsloth/functiongemma-270m-it`
- Method: 16-bit LoRA (r=16, alpha=16; q/k/v/o + gate/up/down) via Unsloth, on a free Tesla T4
- LR 2e-4, linear schedule, `adamw_8bit`, 3 epochs, response-only loss masking
- Synthetic instruction -> tool-call data with contrastive confusable pairs and broad phrasing variety

## License

Governed by the [Gemma Terms of Use](https://ai.google.dev/gemma/terms). Inherits the base model license.