Gowshik S
All posts

I Built a Voice Agent That Sees Your Screen and Acts Across Your Apps

How Rio works: a split between local hands and a cloud brain, a binary WebSocket protocol, native audio, real interruptions and a bridge for tools.

Published
Reading time
5 minutes
Project
Rio case study

Most AI agents make you do the work.

You write the prompt carefully. You wait. It misunderstands. You rephrase and wait again. That isn't autonomy. It's a smarter search bar.

I wanted an agent you speak to once, naturally. You can interrupt it mid-sentence or change your mind, and it keeps up. Then it acts, across your applications, without follow-up prompts.

That agent is Rio.

What Rio does

The simplest example:

I say: "Log this as a support ticket. My order hasn't arrived in five days."

Rio recognises a support request, pulls the issue, severity and category out of what I said, writes a row to Google Sheets with a ticket ID, a timestamp and the status OPEN, and tells me: "Your ticket #007 has been logged."

No typing and no clicking. One instruction, carried all the way through.

While that happens, Rio is also watching my screen. It knows which application is open, it can read text off the display, and it picks up context I never said out loud.

Local hands, cloud brain

Rio is split in two, and that one decision made everything else work.

Rio's split between your machine and the cloudEverything that must be fast stays next to the hardware. Everything that must be powerful runs in the cloud. One WebSocket carries all of it, with audio sent first. Your machineowns the hardwaremicrophonescreenclicks and typingfilesbrowserCloud Runowns the thinkingGemini Live sessionADK orchestrationmodel routingToolBridgeone binary WebSocket0x01 · audio, sent first0x02 · screen framesJSON · tool calls and results
Swipe sideways to see the whole diagram. Everything that must be fast stays next to the hardware. Everything that must be powerful runs in the cloud. One WebSocket carries all of it, with audio sent first.

The things that must be fast, such as capturing audio, grabbing screen frames and clicking, live next to the hardware. The things that must be powerful, such as inference, multi-step planning and API calls, live in the cloud.

Mixing them hurts both. Splitting them lets each side do what it is good at.

One connection, and audio always wins

Audio, video and tool calls all travel over a single WebSocket. I gave it a simple binary prefix:

  • 0x01 followed by 16 kHz mono PCM16 audio, for the Gemini Live session
  • 0x02 followed by JPEG bytes, for the vision pipeline
  • JSON frames for tool calls, results and control signals

The catch: audio and video can't share a queue fairly. One large JPEG would hold the audio back by hundreds of milliseconds.

So the sending side uses a priority queue. Audio goes at priority 0 and frames at priority 1. Audio always wins.

Native audio, not speech-to-text and back

This is the part of the design I'm proudest of.

Most voice agents are text agents in a voice costume: speech-to-text, then a language model, then text-to-speech. The delay is tolerable. The naturalness isn't.

Rio uses Gemini's native audio model, gemini-live-2.5-flash-native-audio. Voice goes in and voice comes out, with no transcript in between. The model hears tone, pace and hesitation, and it answers like a conversation rather than a query.

There is a trade-off. Native audio models are unreliable at calling functions, so I route every tool call through a text-based orchestrator, with live_model_tools=False. That means a hidden translation step between what the model says and what the tool dispatcher hears. Getting that step clean took more iterations than anything else in the build.

Interruptions that feel instant

Handling interruptions properly is harder than it sounds.

The naive approach is to stop playback when you hear sound. That breaks all the time: background noise, a breath, a pause mid-thought.

Rio runs Silero VAD, a trained voice-activity model, inside the sounddevice callback thread. When it detects real speech, it hands off to the asyncio event loop with call_soon_threadsafe.

The hard part is speed. From detection to silence has to stay under about 100 ms, or the interruption feels laggy. Most of that time is spent crossing the boundary between the audio thread and asyncio, so that is where the tuning went.

The ToolBridge

This is the pattern I'm most likely to reuse.

The model runs on Cloud Run, but the actions happen on my machine. It can't reach them directly, so I built a bridge:

Python
# Cloud side: when the model calls a tool
async def bridge_tool_call(name, args):
    call_id = str(uuid.uuid4())
    future = asyncio.Future()
    pending[call_id] = future

    await ws.send_json({"type": "tool_call", "id": call_id, "name": name, "args": args})
    return await asyncio.wait_for(future, timeout=30)

# Local side: when a tool call arrives
async def handle_tool_call(msg):
    result = await execute_tool(msg["name"], msg["args"])
    await ws.send_json({"type": "tool_result", "id": msg["id"], "result": result})

Each tool is an async function kept separate per WebSocket connection. Adding a new one takes about ten lines, and the model never knows it is talking to a machine on the other side of the internet.

Noticing when you struggle

Most agents don't adapt to the person using them. Rio does.

A small scikit-learn classifier runs in real time on how you are interacting: how often you retry, how many errors you hit, how much your response times vary. When it predicts that you are struggling, Rio changes its style on its own. Simpler language, more guidance, without being asked.

The hard part was the features. Hesitation alone isn't struggle, and neither is a single retry. The signal is in the combination, and finding it meant building a small labelled dataset from my own usage logs.

Degrade, never crash

Free-tier API limits are real, and 30 requests a minute go quickly. Rio has a token-bucket rate limiter with levels of graceful degradation:

LevelBucketWhat Rio does
0HealthyEverything
170%Takes fewer screenshots
240%Stops looking at the screen unprompted
310%Voice only, no tools
4EmptyHolds politely and tells you why

The agent never crashes. It degrades.

What I'd do differently

  • Design the protocol first. I added the binary frames on top of a JSON-only WebSocket. It worked, but doing it up front would have saved two days of refactoring.
  • Put the struggle detector inside the agent loop from the start. I built it as a separate pipeline first and then found it only helps when it can act, not just observe.
  • Don't keep sessions only in memory. InMemorySessionService is fine in development. The first time Cloud Run starts a fresh instance mid-conversation, the session is gone. Plan for saved sessions from day one.

What's next

The current Rio is one capable agent. The next version is four:

  • Orchestrator: ADK with Gemini 2.5 Pro, plans and delegates
  • Live agent: owns all voice and vision
  • UI navigator: Playwright and Computer Use for real visual grounding
  • Creative agent: mixed-media output

They will talk over the A2A protocol, with Agent Cards, so Rio becomes one node in a larger network of agents rather than a standalone tool.

Code on GitHubGemini-Live-Agent on GitHub

The repo deploys to Cloud Run with one command:

Terminal
gcloud run services replace cloud/service.yaml

If you're building with the Gemini Live API or ADK, I'd like to compare notes. The full story is in the Rio case study.

One human. One instruction. Rio does the rest.

An earlier version of this post appeared on DEV