Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions config/agent/Fara-7B.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Microsoft Fara-7B (Qwen2.5-VL-7B fine-tuned for web computer use), with its
# native prompt and output grammar via the fara action_parser.
# The system prompt is microsoft/fara's (FaraComputerUse + FN_CALL_TEMPLATE),
# without visit_url / web_search: the apps are local, with no address bar or
# search engine. {display_width_px}x{display_height_px} is filled in per
# viewport with the screenshot size the model sees; its coordinates are read
# as viewport pixels (see action_parsers/fara.py).
# Set hostname/port to your served model before running.
defaults:
- default
- _self_
model_name: microsoft/Fara-7B
model_pretty_name: Fara-7B
hostname: null
host_name_updated_on: null
client_type: vllm
# microsoft/fara samples at temperature 0. Its replies are one or two
# sentences and a tool call; the cap only stops a runaway.
temperature: 0.0
max_tokens: 1024

use_axtree: false
use_screenshot: true

action_parser: fara

prompt_sections:
- task
- history

# What the action_parser emits: left_click -> mouse_click, mouse_move,
# type -> click_and_type, key -> keyboard_press, scroll, wait /
# pause_and_memorize_fact -> noop, history_back -> go_back, terminate ->
# send_msg_to_user (success) or report_infeasible (failure).
custom_actions:
- mouse_click
- mouse_move
- click_and_type
- keyboard_press
- scroll
- noop
- go_back
- send_msg_to_user
- report_infeasible

prompt_txt:
system_prompt: |-
You are a helpful assistant.

You are a web automation agent that performs actions on websites to fulfill user requests by calling various tools.
* You should stop execution at Critical Points. A Critical Point would be encountered in tasks like 'Checkout', 'Book', 'Purchase', 'Call', 'Email', 'Order', etc where a binding transaction/agreement would require the user's permission/personal or sensitive information (name, email, credit card, address, payment information, resume, etc) in order to complete a transaction (purchase, reservation, sign-up etc), or to communicate in a way that a human would be expected to do (call, email, apply to a job, etc).
* Solve the task as far as you can up until a Critical Point:
- For example, if the task is to "call a restaurant to make a reservation", you should not actually make the call but should navigate to the restaurant's page and find the phone number.
- Similarly, if the task is to "order new size 12 running shoes" you should not actually place the order but should instead search for the right shoes that meet the criteria and add them to the cart.
- Some tasks, like answering questions, may not encounter a Critical Point at all.

You are provided with function signatures within <tools></tools> XML tags:
<tools>
{"type": "function", "function": {"name": "computer_use", "description": "Use a mouse and keyboard to interact with a computer, and take screenshots.\n* This is an interface to a desktop GUI. You do not have access to a terminal or applications menu. You must click on desktop icons to start applications.\n* Some applications may take time to start or process actions, so you may need to wait and take successive screenshots to see the results of your actions. E.g. if you click on Firefox and a window doesn't open, try wait and taking another screenshot.\n* The screen's resolution is {display_width_px}x{display_height_px}.\n* Whenever you intend to move the cursor to click on an element like an icon, you should consult a screenshot to determine the coordinates of the element before moving the cursor.\n* If you tried clicking on a program or link but it failed to load, even after waiting, try adjusting your cursor position so that the tip of the cursor visually falls on the element that you want to click.\n* Make sure to click any buttons, links, icons, etc with the cursor tip in the center of the element. Don't click boxes on their edges unless asked.\n* When a separate scrollable container prominently overlays the webpage, if you want to scroll within it, you typically need to mouse_move() over it first and then scroll().\n* If a popup window appears that you want to close, if left_click() on the 'X' or close button doesn't work, try key(keys=['Escape']) to close it.\n* On some search bars, when you type(), you may need to press_enter=False and instead separately call left_click() on the search button to submit the search query. This is especially true of search bars that have auto-suggest popups for e.g. locations\n* For calendar widgets, you usually need to left_click() on arrows to move between months and left_click() on dates to select them; type() is not typically used to input dates there.", "parameters": {"properties": {"action": {"description": "The action to perform. The available actions are:\n* `key`: Performs key down presses on the arguments passed in order, then performs key releases in reverse order. Includes \"Enter\", \"Alt\", \"Shift\", \"Tab\", \"Control\", \"Backspace\", \"Delete\", \"Escape\", \"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\", \"PageDown\", \"PageUp\", \"Shift\", etc.\n* `type`: Type a string of text on the keyboard.\n* `mouse_move`: Move the cursor to a specified (x, y) pixel coordinate on the screen.\n* `left_click`: Click the left mouse button.\n* `scroll`: Performs a scroll of the mouse scroll wheel.\n* `history_back`: Go back to the previous page in the browser history.\n* `pause_and_memorize_fact`: Pause and memorize a fact for future reference.\n* `wait`: Wait specified seconds for the change to happen.\n* `terminate`: Terminate the current task and report its completion status.", "enum": ["key", "type", "mouse_move", "left_click", "scroll", "history_back", "pause_and_memorize_fact", "wait", "terminate"], "type": "string"}, "keys": {"description": "Required only by `action=key`.", "type": "array"}, "text": {"description": "Required only by `action=type`.", "type": "string"}, "press_enter": {"description": "Whether to press the Enter key after typing. Required only by `action=type`.", "type": "boolean"}, "delete_existing_text": {"description": "Whether to delete existing text before typing. Required only by `action=type`.", "type": "boolean"}, "coordinate": {"description": "(x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to. Required only by `action=left_click`, `action=mouse_move`, and `action=type`.", "type": "array"}, "pixels": {"description": "The amount of scrolling to perform. Positive values scroll up, negative values scroll down. Required only by `action=scroll`.", "type": "number"}, "fact": {"description": "The fact to remember for the future. Required only by `action=pause_and_memorize_fact`.", "type": "string"}, "time": {"description": "The seconds to wait. Required only by `action=wait`.", "type": "number"}, "status": {"description": "The status of the task. Required only by `action=terminate`.", "type": "string", "enum": ["success", "failure"]}}, "required": ["action"], "type": "object"}}}
</tools>

For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call>

# User-message slots suppressed via prompt_sections above.
output_format: null
action_prompt: null
action_abstract_example: null
action_concrete_example: null
think_prompt: ""
think_abstract_example: ""
think_concrete_example: ""
12 changes: 12 additions & 0 deletions config/agent/OpenCUA-32B.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# XLANG OpenCUA-32B (Qwen2.5-VL-32B fine-tuned for computer use): the
# OpenCUA-7B config (same prompt, action_parser and actions) on the larger
# checkpoint.
# Set hostname/port to your served model before running.
defaults:
- OpenCUA-7B
- _self_
model_name: xlangai/OpenCUA-32B
model_pretty_name: OpenCUA-32B
hostname: null
host_name_updated_on: null
client_type: vllm
112 changes: 112 additions & 0 deletions config/agent/OpenCUA-7B.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# XLANG OpenCUA-7B (Qwen2.5-VL-7B fine-tuned for computer use), with its
# native prompt and output grammar via the opencua action_parser.
# The system prompt is xlang-ai/OSWorld's SYSTEM_PROMPT_V1_L2 for OpenCUA-7B
# and -32B (L2 CoT: Thought, Action, then PyAutoGUI code), without the
# computer's sudo password. Its coordinates are read as described in
# action_parsers/opencua.py.
# OpenCUA was trained with the last three screenshots and earlier steps as
# chat turns; here, as for every agent, the history is text in one user
# message with the current screenshot, written in OpenCUA's own step template
# (see action_parsers/opencua.py).
# Serving: the tokenizer is remote code, and the one on the main branch fails
# to load under Transformers v5; both checkpoints ship the same tokenizer
# files, so load the OpenCUA-7B revision that fixes it (the one vLLM's own
# tests pin). vLLM's OpenCUA processor needs vllm-project/vllm#60823 under
# Transformers v5 (in vLLM >= 0.33):
# vllm serve xlangai/OpenCUA-7B --trust-remote-code \
# --tokenizer xlangai/OpenCUA-7B \
# --tokenizer-revision 50a22000cd3d3b8f187b307bfd3563714854425a
# (the same flags serve xlangai/OpenCUA-32B).
# Set hostname/port to your served model before running.
defaults:
- default
- _self_
model_name: xlangai/OpenCUA-7B
model_pretty_name: OpenCUA-7B
hostname: null
host_name_updated_on: null
client_type: vllm
# OSWorld's OpenCUA runs sample at temperature 0 with a 2048-token cap; an L2
# reply is a few hundred tokens.
temperature: 0.0
max_tokens: 2048

use_axtree: false
use_screenshot: true

action_parser: opencua

prompt_sections:
- task
- history

# What the action_parser emits: click -> mouse_click, doubleClick ->
# mouse_dblclick, rightClick -> mouse_click(button='right'), tripleClick /
# computer.triple_click -> mouse_tripleclick, moveTo -> mouse_move, moveTo +
# dragTo -> mouse_drag_and_drop, write -> keyboard_type (click_and_type when
# it follows a click or precedes Enter), press / hotkey -> keyboard_press,
# scroll / hscroll -> scroll, computer.wait -> noop, computer.terminate ->
# send_msg_to_user (success) or report_infeasible (failure). press with a
# count -> keyboard_press_repeat; scroll at a point (moveTo first, or x/y) ->
# scroll_at.
custom_actions:
- mouse_click
- mouse_dblclick
- mouse_tripleclick
- mouse_move
- mouse_drag_and_drop
- keyboard_type
- keyboard_press
- keyboard_press_repeat
- click_and_type
- scroll
- scroll_at
- noop
- send_msg_to_user
- report_infeasible

prompt_txt:
system_prompt: |-
You are a GUI agent. You are given a task and a screenshot of the screen. You need to perform a series of pyautogui actions to complete the task. If the task is not possible to do, output the action computer.terminate(status='failure').

For each step, provide your response in this format:

Thought:
- Step by Step Progress Assessment:
- Analyze completed task parts and their contribution to the overall goal
- Reflect on potential errors, unexpected results, or obstacles
- If previous action was incorrect, predict a logical recovery step
- Next Action Analysis:
- List possible next actions based on current state
- Evaluate options considering current state and previous actions
- Propose most logical next action
- Anticipate consequences of the proposed action
- For Text Input Actions:
- Note current cursor position
- Consolidate repetitive actions (specify count for multiple keypresses)
- Describe expected final text outcome
- Use first-person perspective in reasoning

Action:
Provide clear, concise, and actionable instructions:
- If the action involves interacting with a specific target:
- Describe target explicitly without using coordinates
- Specify element names when possible (use original language if non-English)
- Describe features (shape, color, position) if name unavailable
- For window control buttons, identify correctly (minimize "—", maximize "□", close "X")
- if the action involves keyboard actions like 'press', 'write', 'hotkey':
- Consolidate repetitive keypresses with count
- Specify expected text outcome for typing actions

Finally, output the action as PyAutoGUI code or the following functions:
- {"name": "computer.triple_click", "description": "Triple click on the screen", "parameters": {"type": "object", "properties": {"x": {"type": "number", "description": "The x coordinate of the triple click"}, "y": {"type": "number", "description": "The y coordinate of the triple click"}}, "required": ["x", "y"]}}
- {"name": "computer.terminate", "description": "Terminate the current task and report its completion status", "parameters": {"type": "object", "properties": {"status": {"type": "string", "enum": ["success", "failure"], "description": "The status of the task"}}, "required": ["status"]}}

# User-message slots suppressed via prompt_sections above.
output_format: null
action_prompt: null
action_abstract_example: null
action_concrete_example: null
think_prompt: ""
think_abstract_example: ""
think_concrete_example: ""
10 changes: 10 additions & 0 deletions src/open_apps/agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ Each parser family carries a default (`uitars`: null, `qwen3vl`: 1000). Override
per model in the agent yaml with `coord_scale: N`. Note this is one scalar applied
against each viewport axis, which is what a *square* normalized grid means — it
cannot express a model predicting in its own non-square resized image space.
Fara-7B (a Qwen2.5-VL fine-tune) has its own parser, `fara`: its prompt states
the screenshot size after the image processor's `smart_resize` (multiples of 28
px, e.g. 1920x1080 -> 1932x1092) via `ActionParser.render_system_prompt`, as
microsoft/fara's harness does, yet measured clicks come back in viewport pixels
at common screen sizes, so the parser passes them through.
OpenCUA-7B/-32B (also Qwen2.5-VL fine-tunes) have their own parser, `opencua`,
for their PyAutoGUI replies; their clicks, measured the same way, are in the
resized screenshot's pixels, so the parser scales each axis by viewport /
resized size. It also writes the text history in OpenCUA's own step template
(`ActionParser.render_history`), which it otherwise copies into its replies.

The most reliable setup is to *declare* the grid in the prompt and set
`coord_scale` to match, rather than reverse-engineering a checkpoint's native
Expand Down
7 changes: 6 additions & 1 deletion src/open_apps/agent/action_parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
from .coords import rescale_xy
from .uitars import UITarsActionParser
from .qwen3vl import Qwen3VLActionParser
from .fara import FaraActionParser
from .opencua import OpenCUAActionParser

REGISTRY: dict[str, type[ActionParser]] = {
"uitars": UITarsActionParser,
"qwen3vl": Qwen3VLActionParser,
"fara": FaraActionParser,
"opencua": OpenCUAActionParser,
}


Expand All @@ -19,7 +23,8 @@ def get_action_parser(
"""Build the action_parser for ``name``.

``coord_scale`` overrides the family's default coordinate space when given;
None keeps the subclass default (uitars: raw pixels, qwen3vl: 0-1000).
None keeps the subclass default (uitars: raw pixels, qwen3vl: 0-1000,
fara: viewport pixels, opencua: see action_parsers/opencua.py).
"""
if not name:
name = "uitars"
Expand Down
15 changes: 15 additions & 0 deletions src/open_apps/agent/action_parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ class ActionParser:
def default_prompts(self) -> dict:
return {}

def render_system_prompt(self, system_prompt: str, viewport: tuple[int, int]) -> str:
"""Fill viewport-dependent placeholders in the yaml's system prompt.

Most families need none; a model told its screen size in the prompt
(Fara) overrides this.
"""
return system_prompt

def render_history(self, actions: list, thoughts: list) -> str | None:
"""The user message's history section, from the displayed actions and
thoughts of earlier steps. None keeps the shared format (vLLM_prompt.History);
a model trained on its own step template (OpenCUA) overrides this.
"""
return None

def parse(self, response: str, viewport: tuple[int, int]) -> ActionParserResult:
"""``viewport`` is (width, height) px. Raise ParseError on bad output."""
raise NotImplementedError
Expand Down
Loading
Loading