𝗠𝘆 𝗧𝘄𝗼 𝗔𝗜 𝗧𝗮𝘀𝗸𝘀 𝗞𝗲𝗽𝘁 𝗙𝗶𝗴𝗵𝘁𝗶𝗻𝗴 𝗳𝗼𝗿 𝘁𝗵𝗲 𝗦𝗮𝗺𝗲 𝗠𝗼𝘂𝘀𝗲

Parallel agent demos look good until two tasks fight for the same mouse.

One task logs into a website. Another task opens a browser. A third task tries to answer a simple question. Suddenly, the system clicks the wrong place or cancels the wrong run. This is not a prompt problem. It is a resource problem.

I learned this while building CliGate. I realized that while code tasks can run in parallel, the desktop is different. You only have one keyboard, one mouse, and one screen. If two agents try to own that surface, they sabotage each other.

My first idea was to cancel the old task when a new one arrived. This was a mistake. A user asking for a status update should not kill a login process.

I had to change the rules.

New rules for agent reliability:

  • Independent tasks run in parallel.
  • Tasks needing the desktop must queue.
  • Cancellation only happens when the user asks.

In CliGate, desktop input works like a lease. One task holds the desktop. Other tasks wait their turn.

The new logic works like this:

  • A new task arrives.
  • Does it need the desktop?
  • If no, run it in parallel.
  • If yes and the desktop is free, take it.
  • If yes and the desktop is busy, join the queue.
  • Only stop if the user says stop.

Retries can make things worse. If a task keeps trying to grab the mouse while another task is typing, it creates interference. The fix is not to retry harder. The fix is to be honest. The assistant should say: "The desktop is busy. I am in the queue. I will start when it is free."

This turns a failure into predictable behavior.

I also added a hard rule: an agent cannot cancel itself. This prevents the agent from panic-clicking its own off switch.

Building AI tools is often about being plain rather than clever.

  • If tasks do not conflict, let them run.
  • If they conflict over a physical resource, queue them.
  • If a user asks for status, give the status.
  • If a user says stop, stop.

This makes the assistant feel more human. It stops fighting for control and starts acting like an operator who understands the difference between a question and a command.

If your AI touches the desktop, remember this: parallel tasks are fine, but physical resources need ownership.

Source: https://dev.to/codekingai/my-two-ai-tasks-kept-fighting-for-the-same-mouse-1hij

Optional learning community: https://t.me/GyaanSetuAi