"""UI-TARS-1.5 and MolmoWeb as released, each in its own agent loop, on MiniWeb human tasks (EXPERIMENT_PLAN, RQ1; 2026-10-03). The counterpart of src/miniweb/evaluation/fara_runner.py for the two other own-loop baselines. uitars UI-TARS-1.5-7B (ByteDance-Seed, Apache-2.0). Prompt and action parser are the released ones (pip `ui-tars`: ui_tars.prompt.COMPUTER_USE_DOUBAO, ui_tars.action_parser.parse_action_to_structure_output). The loop is OSWorld's UI-TARS-1.5 agent (mm_agents/uitars15_v1.py, run_multienv_uitars15_v1.py): system "You are a helpful assistant.", the prompt, then the full response history with the last 5 screenshots, temperature 0, top_p 0.9, max_tokens 500 (OSWorld's frequency_penalty 1 is off by default: see --frequency-penalty). A failed parse is retried up to 3 times at temperature 1, then the episode ends. Coordinates are in the Qwen2.5-VL smart_resize space of the screenshot and are mapped back as parsing_response_to_pyautogui_code does. The pyautogui calls become Playwright mouse and keyboard calls: type -> keyboard.type, plus Enter for a trailing \\n; scroll -> 5 wheel notches of 100 px at the point; wait -> 5 s. The answer is finished(content=...). molmoweb MolmoWeb-4B / -8B (AllenAI, Apache-2.0): the released agent code itself (github.com/allenai/molmoweb: agent.multimodal_agent.MultimodalAgent, utils.envs SimpleEnv and its action executor, utils.eval_utils.episode.Episode) with its benchmark settings: "molmo_web_think" prompts, the last 10 steps as text, no past images, temperature 0.7, top_p 0.8, 1024 new tokens, a 1280x720 viewport. Only the predictor is swapped: their HF predictor's single user turn (prompt text + screenshot), sent to a vLLM OpenAI endpoint (the repo leaves vLLM to users). Serve it with causal attention on image tokens, as their HF predictor runs it (vLLM's Molmo2 default is a bidirectional prefix LM): --hf-overrides {"is_mm_prefix_lm":false}, which granite's ownloop.sh passes. The answer is read as their benchmarks.evaluate does: the last "[ANSWER] ..." message, else the last other message, else the last thought. fara7b Fara-7B (Microsoft, MIT): the released previous-generation agent itself (github.com/microsoft/fara src/, fara.fara_7b: FaraAgent, its BrowserBB browser manager and PlaywrightController), as `fara-cli --fara-7b` and webeval's WebSurferSystem run it: 1440x900, the last 3 screenshots, temperature 0, single-tab mode, their page script. The browser manager is subclassed only to launch our Chromium with our context, in place of Firefox with an Edge user agent. The answer is theirs: the terminate step's thoughts. A parse or action error ends the episode, as in the released loop, and the task is re-run up to 5 times, as webeval (the harness of their published numbers) does by default. opencua OpenCUA-7B (XLANG, MIT): OSWorld's OpenCUAAgent itself (xlang-ai/OSWorld mm_agents/opencua) with the OpenCUA-7B command of run_multienv_opencua.py (--coordinate_type qwen25 --use_old_sys_prompt; l2 CoT, action history, 3 images, temperature 0, top_p 0.9, max_tokens 2048) on a 1920x1080 page, and the loop of lib_run_single.run_single_example_opencua. Only call_llm is swapped (a vLLM endpoint), and the VM's `python -c` is a pyautogui-to-Playwright translation (run_pyautogui, literal calls only). The V1 prompt has no answer field: the answer is the terminate step's answer= if given, else its Thought + Action text. Serve with --trust-remote-code and a tokenizer dir whose tokenizer_config.json drops unk_token/pad_token (the remote TikTokenV3 code rejects them under transformers 5; it derives the same [UNK]/[PAD] itself). Both run in the MiniWeb env (Playwright sync API, DATAGEN_CHROME) and start their own MiniWeb servers on --ports, as miniwebagent.evaluate does. The released code goes on sys.path through --path (default $OWNLOOP_PATH): a directory holding `pip install --no-deps --target
"`), on a Playwright page of
the same screen size, with the mouse position tracked as pyautogui tracks it. One scroll click is 100 px, as in the
UI-TARS translation above."""
SCROLL_PX = 100
API = {"click", "doubleClick", "tripleClick", "rightClick", "middleClick", "moveTo", "moveRel", "move", "dragTo",
"dragRel", "drag", "mouseDown", "mouseUp", "scroll", "vscroll", "hscroll", "write", "typewrite", "press",
"hotkey", "keyDown", "keyUp", "sleep"}
def __init__(self, page):
self.page, self.pos = page, (0.0, 0.0) # Playwright's mouse starts at (0, 0)
def _xy(self, x, y):
if isinstance(x, (tuple, list)):
x, y = x[0], x[1]
if x is None or y is None:
return self.pos
return float(x), float(y)
@staticmethod
def _button(b):
return {"right": "right", "secondary": "right", "middle": "middle"}.get(str(b).lower(), "left")
def moveTo(self, x=None, y=None, duration=0.0, *a, **kw):
self.pos = self._xy(x, y)
self.page.mouse.move(*self.pos, steps=max(1, int(float(duration or 0) * 20)))
def moveRel(self, xOffset=0, yOffset=0, *a, **kw):
self.moveTo(self.pos[0] + float(xOffset or 0), self.pos[1] + float(yOffset or 0))
move = moveRel
def click(self, x=None, y=None, clicks=1, interval=0.0, button="left", *a, **kw):
self.moveTo(x, y)
self.page.mouse.click(*self.pos, button=self._button(button), click_count=max(1, int(clicks)))
def doubleClick(self, x=None, y=None, interval=0.0, button="left", *a, **kw):
self.click(x, y, 2, button=button)
def tripleClick(self, x=None, y=None, interval=0.0, button="left", *a, **kw):
self.click(x, y, 3, button=button)
def rightClick(self, x=None, y=None, *a, **kw):
self.click(x, y, button="right")
def middleClick(self, x=None, y=None, *a, **kw):
self.click(x, y, button="middle")
def mouseDown(self, x=None, y=None, button="left", *a, **kw):
if x is not None:
self.moveTo(x, y)
self.page.mouse.down(button=self._button(button))
def mouseUp(self, x=None, y=None, button="left", *a, **kw):
if x is not None:
self.moveTo(x, y)
self.page.mouse.up(button=self._button(button))
def dragTo(self, x=None, y=None, duration=0.0, button="left", *a, **kw):
self.page.mouse.down(button=self._button(button))
self.pos = self._xy(x, y)
self.page.mouse.move(*self.pos, steps=20)
self.page.mouse.up(button=self._button(button))
def dragRel(self, xOffset=0, yOffset=0, duration=0.0, button="left", *a, **kw):
self.dragTo(self.pos[0] + float(xOffset or 0), self.pos[1] + float(yOffset or 0), button=button)
drag = dragRel
def scroll(self, clicks, x=None, y=None, *a, **kw): # positive clicks scroll up
if x is not None and y is not None:
self.moveTo(x, y)
self.page.mouse.wheel(0, -float(clicks) * self.SCROLL_PX)
vscroll = scroll
def hscroll(self, clicks, x=None, y=None, *a, **kw): # positive clicks scroll right
if x is not None and y is not None:
self.moveTo(x, y)
self.page.mouse.wheel(float(clicks) * self.SCROLL_PX, 0)
def write(self, message, interval=0.0, *a, **kw):
if isinstance(message, (list, tuple)): # typewrite(["a", "enter"]): key names
for k in message:
self.press(k)
return
parts = str(message).split("\n") # pyautogui types "\n" as Enter
for i, part in enumerate(parts):
if part:
self.page.keyboard.type(part)
if i < len(parts) - 1:
self.page.keyboard.press("Enter")
typewrite = write
def press(self, keys, presses=1, interval=0.0, *a, **kw):
for _ in range(max(1, int(presses))):
for k in (keys if isinstance(keys, (list, tuple)) else [keys]):
self.page.keyboard.press(py_key(k))
def hotkey(self, *keys, **kw):
keys = [py_key(k) for k in (keys[0] if len(keys) == 1 and isinstance(keys[0], (list, tuple)) else keys)]
for k in keys:
self.page.keyboard.down(k)
for k in reversed(keys):
self.page.keyboard.up(k)
def keyDown(self, key, *a, **kw):
self.page.keyboard.down(py_key(key))
def keyUp(self, key, *a, **kw):
self.page.keyboard.up(py_key(key))
def sleep(self, seconds=0, *a, **kw):
time.sleep(min(max(float(seconds), 0.0), 60.0))
class UnsupportedCode(Exception):
"""A statement that the `pyautogui` + `time` namespace of OSWorld's VM would not run (e.g. computer.triple_click:
their prompt lists it, but their loop passes it to the VM's python, where it is a NameError)."""
def run_pyautogui(code, gui):
"""OpenCUA's code, statement by statement, as `python -c` runs it: the first failing statement stops the rest.
Model output is never exec'd: only literal-argument calls of pyautogui.* and time.sleep, `import pyautogui|time`,
`pass`, and `for _ in range():` loops over those statements run."""
import ast
def call(c):
f = c.func
if not (isinstance(f, ast.Attribute) and isinstance(f.value, ast.Name)):
raise UnsupportedCode(f"unsupported call: {ast.unparse(c)[:120]}")
mod, name = f.value.id, f.attr
args = [ast.literal_eval(a) for a in c.args]
kwargs = {k.arg: ast.literal_eval(k.value) for k in c.keywords if k.arg}
if mod == "time" and name == "sleep":
return gui.sleep(*args, **kwargs)
if mod == "pyautogui" and name in gui.API:
return getattr(gui, name)(*args, **kwargs)
raise UnsupportedCode(f"{mod}.{name} is not defined")
def stmt(node):
if isinstance(node, ast.Import) and {a.name for a in node.names} <= {"pyautogui", "time"}:
return
if isinstance(node, ast.Pass):
return
if isinstance(node, ast.Expr) and isinstance(node.value, ast.Call):
return call(node.value)
if (isinstance(node, ast.For) and not node.orelse and isinstance(node.iter, ast.Call)
and isinstance(node.iter.func, ast.Name) and node.iter.func.id == "range"):
n = range(*[int(ast.literal_eval(a)) for a in node.iter.args])
for _ in range(min(len(n), 100)):
for s in node.body:
stmt(s)
return
raise UnsupportedCode(f"unsupported statement: {ast.unparse(node)[:120]}")
for node in ast.parse(code).body:
stmt(node)
def chat_full(client, model, messages, **kw):
"""chat() that also returns the finish reason; a 400 (e.g. a prompt over the context) is the request's own error,
not an endpoint failure."""
import openai
for attempt in range(3):
try:
r = client.chat.completions.create(model=model, messages=messages, **kw)
return r.choices[0].message.content or "", r.choices[0].finish_reason
except openai.BadRequestError:
raise
except Exception as e:
if attempt == 2:
raise EndpointError(f"{type(e).__name__}: {str(e)[:200]}") from e
time.sleep(5)
_OPENCUA = {}
def opencua_agent_class():
"""Their OpenCUAAgent (xlang-ai/OSWorld mm_agents/opencua) with call_llm pointed at a vLLM endpoint. Everything else
is theirs: the prompt, the history, the retries, the parsing and the coordinate projection."""
with _IMPORT_LOCK:
if "cls" in _OPENCUA:
return _OPENCUA["cls"]
from loguru import logger
logger.remove() # their module logs every prompt and response through loguru
from mm_agents.opencua.opencua_agent import OpenCUAAgent
class VllmOpenCUAAgent(OpenCUAAgent):
"""Their call_llm posts to their hosted endpoint and re-posts the same payload (up to 20 times) until
finish_reason == "stop". At temperature 0 a re-post repeats the same output, so here a non-"stop" finish
returns None at once; their predict() then retries (5 calls in all, temperature >= 0.2 after the first)."""
def __init__(self, client, deadline, **kw):
super().__init__(**kw)
self.client, self.deadline = client, deadline
self.calls, self.endpoint_failed, self.timed_out = [], None, False
def call_llm(self, payload, model):
if self.endpoint_failed:
raise EndpointError(self.endpoint_failed)
if time.time() > self.deadline:
self.timed_out = True
raise TimeoutError("task timeout")
try:
text, finish = chat_full(self.client, **payload)
except EndpointError as e:
self.endpoint_failed = str(e)
raise
except Exception as e:
self.calls.append({"error": f"{type(e).__name__}: {str(e)[:300]}",
"temperature": payload.get("temperature")})
raise
self.calls.append({"raw": text, "finish_reason": finish, "temperature": payload.get("temperature")})
return text if finish == "stop" else None
_OPENCUA["cls"] = VllmOpenCUAAgent
return VllmOpenCUAAgent
def opencua_answer(cot):
"""The answer of a terminate step: its answer= argument (their V2 prompt's terminate has one) if given, else the
step's Thought and Action text. OpenCUA-7B's V1 prompt has no answer field, and OSWorld grades no text answers."""
import ast
code = cot.get("original_code") or ""
try:
for node in ast.walk(ast.parse(code)):
if isinstance(node, ast.Call) and getattr(node.func, "attr", None) == "terminate":
for k in node.keywords:
if k.arg == "answer":
return str(ast.literal_eval(k.value))
except Exception:
m = re.search(r"answer\s*=\s*('''|\"\"\"|'|\")(.*?)\1", code, re.S)
if m:
return m.group(2)
return "\n".join(p for p in (cot.get("thought"), cot.get("action")) if p) or None
def front_page(ctx, page):
"""The page on screen: a click may open a tab, which a desktop browser brings to the front."""
pages = [p for p in ctx.pages if not p.is_closed()]
page = pages[-1] if pages else page
try:
page.wait_for_load_state("domcontentloaded", timeout=5000)
except Exception:
pass
return page
def run_opencua(t, base, args, ep):
"""OSWorld's OpenCUA-7B command (run_multienv_opencua.py --coordinate_type qwen25 --use_old_sys_prompt, the
defaults: cot_level l2, action_history, 3 images, temperature 0, top_p 0.9, max_tokens 2048) and loop
(lib_run_single.run_single_example_opencua) on a 1920x1080 page: predict, then each returned action through
env.step semantics (DONE / FAIL end the episode, WAIT sleeps, pyautogui code runs), each step followed by
sleep_after_execution (5 s)."""
from openai import OpenAI
from playwright.sync_api import sync_playwright
start = t["start"].replace("{BASE}", base)
prompt = t["prompt"].replace("{BASE}", base)
flags = base + "/_admin/session-flags" + ("?logout=1" if t["needs_login"] else "")
res = {"task_id": t["task_id"], "base": base, "answer": None, "status": None, "rounds": 0, "error": None,
"record": [], "log": [], "seconds": None, "parse_fails": 0, "action_errors": 0}
t0, rec = time.time(), Rec(ep)
agent = opencua_agent_class()(
OpenAI(base_url=args.endpoint, api_key="not-needed", timeout=300), t0 + args.timeout,
model=args.model, history_type="action_history", max_steps=args.max_steps, max_image_history_length=3,
platform="ubuntu", max_tokens=args.opencua_max_tokens, top_p=0.9, temperature=0.0, action_space="pyautogui",
observation_type="screenshot", cot_level="l2", screen_size=(args.width, args.height), coordinate_type="qwen25",
use_old_sys_prompt=True)
task = instruction(prompt, start)
pause = args.opencua_pause
with sync_playwright() as pw:
browser = launch_browser(pw)
ctx = new_context(browser, args.width, args.height)
try:
page = ctx.new_page()
page.goto(flags, wait_until="domcontentloaded", timeout=60000)
page.goto(start, wait_until="domcontentloaded", timeout=60000)
time.sleep(1.0)
gui = PyAutoGUI(page)
for i in range(1, args.max_steps + 1):
if time.time() - t0 > args.timeout:
res["status"] = "timeout"
break
png = page.screenshot(type="png")
rec.shot(i, png)
n_actions, n_calls = len(agent.actions), len(agent.calls)
response, actions, cot = agent.predict(task, {"screenshot": png})
calls, accepted = agent.calls[n_calls:], len(agent.actions) > n_actions
res["rounds"] = i
res["parse_fails"] += len(calls) - accepted
row = {"step": i, "url": page.url, "raw": response if accepted else None,
"attempts": calls if len(calls) != 1 or not accepted else None, "action": cot.get("action"),
"code": cot.get("original_code"), "executed": actions}
if agent.endpoint_failed or agent.timed_out or not accepted:
rec.step(**row, error=response)
res["status"] = "endpoint_error" if agent.endpoint_failed else "timeout" if agent.timed_out \
else "parse_error" # their predict: 5 failed calls -> FAIL, the episode ends
res["error"] = agent.endpoint_failed or str(response)[:300]
break
if not actions or actions[0] == "" or actions[0].lower().startswith("error"):
rec.step(**row)
res["status"] = "no_action"
break
stop, notes = False, []
for a in actions:
note = ""
if a in ("DONE", "FAIL"):
stop = True
elif a == "WAIT":
time.sleep(pause) # env.step sleeps `pause` for WAIT, then once more
else:
try:
run_pyautogui(a, gui)
except Exception as e:
note = f"{type(e).__name__}: {str(e)[:200]}"
res["action_errors"] += 1
notes.append(note)
if stop:
break
time.sleep(pause)
gui.page = page = front_page(ctx, page)
rec.step(**row, notes=notes)
if stop:
code = (cot.get("original_code") or "").lower()
if "computer.terminate" in code: # theirs: "fail" in the code -> FAIL, else "success"
res["status"] = "fail" if "fail" in code else "done"
res["answer"] = opencua_answer(cot)
else: # predict() forces FAIL at the step budget
res["status"] = "max_steps"
break
else:
res["status"] = "max_steps"
try:
rec.shot(res["rounds"] + 1, front_page(ctx, page).screenshot(type="png"))
except Exception:
pass
except Exception as e: # a harness error still keeps whatever the session did
res["error"] = f"{type(e).__name__}: {str(e)[:300]}"
res["status"] = res["status"] or "error"
try:
res["record"] = admin_entries(ctx, base, "/_admin/record")
res["log"] = admin_entries(ctx, base, "/_admin/log")
except Exception as e:
res["error"] = (res["error"] or "") + f" | backend read: {type(e).__name__}: {str(e)[:200]}"
browser.close()
rec.close()
res["seconds"] = round(time.time() - t0, 1)
return res
# ── driver ────────────────────────────────────────────────────────────────────────────────────────────────────────────
RUNNERS = {"uitars": (run_uitars, (1280, 800)), "molmoweb": (run_molmoweb, (1280, 720)),
"fara7b": (run_fara7b, (1440, 900)), "opencua": (run_opencua, (1920, 1080))}
def main(argv=None):
ap = argparse.ArgumentParser()
ap.add_argument("agent", choices=sorted(RUNNERS))
ap.add_argument("--tasks", required=True, help="tasks.json of `python -m miniweb.evaluation.fara_rq1 prep`")
ap.add_argument("--out", required=True)
ap.add_argument("--ports", required=True, help="MiniWeb server ports to start (8300-8320), e.g. 8312,8313")
ap.add_argument("--endpoint", required=True, help="vLLM OpenAI endpoint, e.g. http://127.0.0.1:8694/v1")
ap.add_argument("--model", required=True, help="served model name")
ap.add_argument("--path", default=os.environ.get("OWNLOOP_PATH", ""),
help="colon list prepended to sys.path: the ui-tars --target dir, the molmoweb clone")
ap.add_argument("--workers", type=int, default=8)
ap.add_argument("--max-steps", type=int, default=40, help="model actions per task (our MiniWeb budget: 40)")
ap.add_argument("--timeout", type=int, default=1800)
ap.add_argument("--width", type=int, default=0, help="viewport; default uitars 1280x800, molmoweb 1280x720")
ap.add_argument("--height", type=int, default=0)
ap.add_argument("--frequency-penalty", type=float, default=0.0,
help="uitars: 0 as the UI-TARS README's deployment example; OSWorld's request sends 1, which turned "
"answers that repeat the thought's words into Chinese in the smoke test")
ap.add_argument("--temperature", type=float, default=0.7, help="molmoweb sampling (their default)")
ap.add_argument("--top-p", type=float, default=0.8)
ap.add_argument("--max-past-steps", type=int, default=10, help="molmoweb text history (their benchmark default)")
ap.add_argument("--fara7b-error-retries", type=int, default=5,
help="fara7b: webeval's --max_error_task_retries (an episode that raised is re-run)")
ap.add_argument("--opencua-max-tokens", type=int, default=2048,
help="opencua: run_multienv_opencua.py's --max_tokens (the agent class's own default is 1500)")
ap.add_argument("--opencua-pause", type=float, default=5.0,
help="opencua: run_multienv_opencua.py's --sleep_after_execution, slept after every action")
ap.add_argument("--limit", type=int, default=0)
ap.add_argument("--task-ids", default="")
args = ap.parse_args(argv)
for p in reversed([p for p in args.path.split(":") if p]):
sys.path.insert(0, p)
run, (w, h) = RUNNERS[args.agent]
args.width, args.height = args.width or w, args.height or h
out = Path(args.out)
tasks = json.loads(Path(args.tasks).read_text())
if args.task_ids:
keep = set(args.task_ids.split(","))
tasks = [t for t in tasks if t["task_id"] in keep]
done = {p.parent.name for p in out.glob("*/session.json")}
tasks = [t for t in tasks if t["task_id"] not in done] # resume
if args.limit:
tasks = tasks[:args.limit]
from miniwebgen import browser as B
lock, queue = threading.Lock(), list(tasks)
ports = [int(p) for p in args.ports.split(",")]
with B.Servers(n=len(ports), ports=ports) as srv:
bases = srv.bases
print(f"{args.agent}: {len(tasks)} tasks, {args.workers} workers on {bases}", flush=True)
def worker(i):
while True:
with lock:
if not queue:
return
t = queue.pop(0)
ep = out / t["task_id"]
ep.mkdir(parents=True, exist_ok=True)
try:
r = run(t, bases[i % len(bases)], args, ep)
except Exception as e:
r = {"task_id": t["task_id"], "base": bases[i % len(bases)], "answer": None, "status": "crash",
"rounds": 0, "error": f"{type(e).__name__}: {str(e)[:300]}", "record": [], "log": []}
# a harness or model-server failure is kept aside, unsaved, so a rerun (resume) repeats the task
name = "session_failed.json" if r["status"] in ("crash", "endpoint_error") else "session.json"
(ep / name).write_text(json.dumps(r, default=str))
print(f"{t['task_id']}: status={r['status']} rounds={r['rounds']} {r.get('seconds')}s "
f"parse_fails={r.get('parse_fails')} action_errors={r.get('action_errors')} err={r['error']} "
f"answer={str(r['answer'])[:80]!r}", flush=True)
with ThreadPoolExecutor(args.workers) as ex:
list(ex.map(worker, range(args.workers)))
if __name__ == "__main__":
main()