UI-TARS Desktop cancels every step at 30 seconds? It's a hard-coded timeout — how to prove it, and what the fix involves
This is the second article in this series. The first one covered getting local AI running on a Polaris card via Vulkan at all. This one is about a single defect that nearly ended the desktop-agent part of that project on its first evening — and that will eat yours too if you run UI-TARS Desktop against a local model server on modest hardware.
The rig, for reference: a modded RX 580 (Polaris, gfx803) with 16 GB of VRAM, a 2-core Celeron with no AVX2, 16 GB of DDR4, Windows 11. The stack: UI-TARS-1.5-7B served by llama.cpp's llama-server, driven by UI-TARS Desktop v0.2.4 — the last release of the Desktop line, which is now archived. Everything below was proven against that version specifically.
The symptom
The agent starts a task. The first step or two complete. Then a step runs long — and at roughly 30 seconds it is cancelled and reported as a "Connection error." The run dies or retries pointlessly. Meanwhile, the llama-server log is perfectly clean: no crash, no error, no out-of-memory, nothing. The server was still working on its answer when the app stopped listening.
That combination — steps dying at a suspiciously round number, with a healthy server — is the whole story. The rest of this article is proving it and understanding what fixing it actually takes.
The dead ends everyone tries first
Because the error says "Connection," people debug the connection. They restart the server. They try a different model. They check the base URL, the port, the firewall, the API-key field. They reinstall. They blame the graphics card, because on legacy hardware the card is guilty until proven innocent.
None of it helps, because none of it is the problem. Two observations rule the whole server side out before you touch anything:
A clean server log is evidence, not an absence of it. If the model, the card, or VRAM were failing, llama-server would say so — it is not shy about logging allocation failures and device losses. A log that shows the request arriving and generation proceeding normally, right up until the client vanishes, is the server testifying that it was fine.
A bound port proves nothing — but the model list does. llama-server binds its port before the model finishes loading, so "the port answers" is not proof of health. The check that counts is the model alias answering at http://127.0.0.1:8080/v1/models. If your alias is listed there, the server is up, loaded, and serving. Whatever is killing your steps, it is downstream of a healthy server.
The fingerprint: a ceiling in your timings
Here is the evidence that convicted the app, from a full day of field logs on the rig above.
On this class of hardware, a legitimate agent step — screenshot, vision encode, model thinking, action out — takes 20 to 28 seconds. That is normal. It is also, notice, uncomfortably close to 30.
Now the fingerprint: in an entire day of logs, no completed step ever exceeded 28.1 seconds. Not one. And the steps that died were cancelled at 27.2 s and 29.6 s. Think about what that means. Real work has a distribution — some steps at 19 s, some at 24 s, occasionally one at 34 s that still finishes. A hard ceiling that no successful step ever crosses, with failures clustered just under it, is not a distribution. It is a guillotine. Something was cutting every request at the same height, and 28.1 s was simply the longest step that ever squeezed under the blade.
If your steps die at random times with errors in the server log, you have a different failure — work the server side. But if they die at ~27–30 s against a clean log, you have this one.
The root cause
UI-TARS Desktop 0.2.4 hard-codes a 30-second timeout on model requests: the literal timeout: 3e4 — 3e4 is 30,000 milliseconds — in two places inside invokeModelProvider in the app's bundled dist/main/main.js (in the 0.2.4 build they sit at lines 73336 and 73363, one for each of the app's two model-call paths). There is no settings field for it. No config file exposes it. It is a constant, compiled into the bundle, chosen by someone who presumably assumed the model would be a fast cloud API. Against a local model on a 2-core machine, 30 seconds is not a timeout — it's a coin flip that lands wrong a third of the time.
How to prove it on your own machine
You don't need my logs. Run these checks in order:
- Time your steps. Watch a run and note where steps complete and where they die. If completed steps pile up under ~28 s and nothing — ever — completes above it, while failures cluster at ~27–30 s, that's the fingerprint.
- Read the server log during a failure. Request arrived, generation running, no error — then the client disconnects. Healthy server, impatient client.
- Confirm the server independently. Load
http://127.0.0.1:8080/v1/modelsin a browser. Your model alias should be listed. Server: innocent. - Find the literal. The app's code ships in an archive called
app.asarin the install folder. Extract it (or search an extracted copy) and look indist/main/main.jsfortimeout: 3e4nearinvokeModelProvider. Two occurrences in 0.2.4. One caution from the field: search anchored on thetimeout:property — a bare30000also appears in port numbers and animation delays, and those are not yours to change.
If all four line up, you don't have a server problem, a model problem, or a hardware problem. You have a constant.
What the fix actually involves
At orientation level, the fix is simple to state: raise both timeouts from 3e4 to 6e5 — ten minutes — so a slow local step is allowed to finish. And after patching, the proof was unambiguous: pointed at a deliberately slow CPU-encode server whose steps used to die at 29.6 s, the patched app completed model invokes of 300, 298, and 372 seconds. The wall was the app. It always was.
What makes it a job rather than an edit is everything around that one-line change:
- The code lives inside
app.asar, an archive. Editing it means extracting the archive, changing the file, and repacking it — into a new file first, so a failed pack can never replace a working archive. - The repack has a trap: some native modules must stay outside the archive in an unpacked folder. Seal them in and the app breaks.
- The executable checks the archive's integrity. UI-TARS.exe embeds the SHA-256 hash of the archive's header and verifies it at launch. Repack without updating that hash and the app refuses to start, with no useful error. The replacement works cleanly because the hash is stored as a 64-character hex string — the new hash is exactly as long as the old one, so nothing else in the executable moves.
- Backups are the whole safety net:
app.asar, its unpacked folder, andUI-TARS.exe, copied somewhere safe before you touch anything. Restoring those three returns the app to stock, untouched.
This is also why I'd argue for a scripted patch over hand-editing: a script can anchor on the timeout: property (and only that), count its replacements, recompute both hashes from the archives, swap the new one in, and verify its own work before declaring success. A hex editor does none of that, and the failure mode of getting it wrong is an app that won't start and no note about why. One more honesty note: this patch is version-specific. It was proven on Desktop 0.2.4; another build may word or place the value differently, and any tooling worth using should report "not found" rather than guess.
The other half: making steps faster so the timeout matters less
Raising the wall buys you room; it doesn't make steps quick. Two settings decide how long a step takes on this stack, and readers hitting the timeout usually need both:
Offload the vision projector. Launch llama-server with --mmproj-offload so the screenshot encode runs on the GPU. Without it, the encode runs on the CPU — on the 2-core field rig that took ~85 seconds per screenshot, and every step died waiting (that was true even before the timeout entered the picture). With the projector on the GPU, steps land around ~20 seconds.
Cap the vision tokens. --image-max-tokens 768 is the field-proven setting. Uncapped, the vision encode crashed the graphics card outright (ggml_vulkan: device lost). At 512 the agent is stable but can't aim — clicks land wrong. At 1024 it aims best but steps run 25–28 s, which is precisely why that setting was unusable until the timeout was patched. Hold the server context at -c 8192 while you're at it: the agent's memory is screenshots, and every remembered screen costs roughly a thousand tokens.
The known-good launch line, for reference:
llama-server.exe -m <UI-TARS-1.5-7B.gguf> --mmproj <mmproj.gguf> --mmproj-offload -ngl 999 -c 8192 --jinja --image-max-tokens 768 -a UI-TARS-1.5-7B --host 127.0.0.1 --port 8080 Working discipline, briefly
The timeout was the mechanical failure. The other failure mode is asking the agent to do too much per run, and no patch fixes that:
- One short, single-purpose task per run. "Open Display settings and report the resolution" — perfect. A five-part mission is a slow-motion failure.
- Word tasks keyboard-first. Win+R and
ms-settings:routes beat menu-hunting every time: every menu hunted is steps, tokens, and chances to get lost. - Start read-only. "Look and report, change nothing" until a new task type has earned trust.
- Supervise, always. It holds your real mouse and keyboard. Stop button over mouse-fighting, and nothing sensitive on screen.
The proof it all works together: with the GPU server at the 768 cap and the patched app, the task "Press Win+R, type ms-settings:display, press Enter, tell me the display resolution" ran clean to completion and reported 1920 × 1080 — correct. A 2-core Celeron and a 2017 graphics card, driving Windows by itself, once the app stopped hanging up on it mid-sentence.
If you want the patch done for you
Full disclosure: these are my own products, built from the exact notes above.
The patch described here — the timeout fix, the repack, the hash swap, all scripted with a dry-run first and self-verification, plus the context-pruning settings — is packaged as an agent skill on Agensi: UI-TARS Timeout Patch & Context Pruner, $9.99. An AI assistant with that skill applies the whole procedure to your machine instead of you hand-editing an archive at midnight.
The other three pieces of the stack are skills too:
- stable-diffusion.cpp Vulkan Setup for Legacy AMD GPUs
- stable-diffusion.cpp Vulkan & VRAM Diagnostic for Legacy AMD
- llama.cpp Vulkan Chat Setup for Legacy AMD GPUs
The full written version is my playbook, Local AI on Hardware the Big Tools Gave Up On: the $19 playbook, or the $29 bundle with the working scripts — including the timeout patcher and hash swapper — and the control deck source. Everything lives on my creator page: agensi.io/creators/nick-2.
And if you're starting from zero on the hardware side, the first article in this series covers the full Vulkan setup — the dead ends, the launch lines, and the context ladder — that this one builds on.
Either way: time your steps before you debug anything. The clock knew the answer the whole time.