Dev.to AI 🤖 Ai 👁 0 📖 4 min read

How I built a narrator for my desktop AI companion: 1 sentence, 180 characters, and a 3-second budget

How I built a narrator for my desktop AI companion: 1 sentence, 180 characters, and a 3-second budget Ankita AI is the desktop AI assistant I'm building — a little companion that lives on your desktop and gets things d

How I built a narrator for my desktop AI companion: 1 sentence, 180 characters, and a 3-second budget

Ankita AI is the desktop AI assistant I'm building — a little companion that lives on your desktop and gets things done while you're away. I built it because a voice assistant that goes quiet for a minute while it works is indistinguishable from one that died. The fix sounds simple: narrate what it's doing. The hard part is that every obvious way to do it lies.

A canned line — "Working on it…" — lies by omission: it says the same thing whether the job is running, stuck, or waiting on a permission. A model-written update lies by commission: give a model a tool transcript and it will cheerfully tell you the file is saved before the write has even started. So the narrator in Ankita is a separate, deliberately small model call with a prompt that is mostly rules about what it must not claim. The project site is at ankita-sable.vercel.app.

One sentence, and the budget that enforces it

The narrator lives in src/core/voice-narrator.mjs, behind createVoiceNarrator(). The constants are the whole design:

  • VOICE_NARRATION_TIMEOUT_MS — 3,000 ms. A progress update that arrives after the work is done is worse than silence, so the call is aborted at 3 seconds.
  • NARRATION_MAX_CHARS — 180. One short, complete spoken sentence, not a tool transcript.
  • NARRATION_MAX_TOKENS — 1,024 output tokens, including the model's mandatory reasoning. The test pins this explicitly: optional narration must not inherit the full file-generation budget.
  • NARRATION_MAX_STEPS — 3. Only the three most recent observed steps go in.
  • REQUEST_MAX_CHARS — 300. Enough of the task intent, without sending the conversation or memory again.

The prompt demands one complete sentence, preferably under sixteen words, at most twenty — and then spends most of its length on honesty rules. "Requested means preparation, not execution: permission or a shared resource may still be pending. Never say an action is underway until its started observation." A write_file saves directly to disk; it is not typing inside an app. A background run_command receipt only acknowledges submission: it does not prove an app is open or a process finished. Never invent a time estimate. And if there is no useful supported change, output an empty response.

What the model is allowed to see

The narrator never sees tool arguments. voiceActionContext() in src/automation/voice-progress.mjs builds the facts the model gets: the tool name, the basename of a target path, the program basename from a shell command — capped at 80 characters, shell expressions rejected by a SAFE_PROGRAM check. No file bodies, no full paths, no command arguments. Everything is passed through redactText() with the configured secrets first, and the previous update is sent along so the model can be told not to repeat it.

The test suite checks the boundary rather than trusting it. One test sends a write_file call whose arguments contain a private file body and a fixture API key, then asserts neither string appears anywhere in the request payload. Another test checks that a save followed by a launch is narrated as two distinct states — "Your poem is saved; I am launching Notepad." — with the run_command marked background: true and the secret argument stripped out. A third test covers the waiting case: a long task gets a generated waiting update, and a 503 from the provider returns an empty string. Failed narration stays silent.

Silence is the failure mode

That last point is the design decision I keep coming back to. Every failure path in the narrator returns '': HTTP error, empty content, an overlong sentence, a repeat of the previous update, a timeout, a request error. The wiring in desktop/electron/voice.mjs makes silence the default — progress() offers the narrated line into the speech queue, and if the line is empty no audio is prepared at all. The narrator runs alongside the tools, never in their critical path; the file's own comment says so.

I chose that because a spoken progress update is a claim about the world, and a wrong claim spoken aloud is harder to take back than a wrong line of text. A canned "Working on it…" can never be wrong, but it can never be useful either. The narrator bets the other way: say something specific, or say nothing.

The honest limits

The bet has holes, and they're worth naming. The honesty rules are prompt instructions, not verification — the model can still misstate state, just with a shorter leash. It sees only the last three steps and a 300-character slice of the request, so it can misattribute which step produced which result. Every update is a separate model call, which costs tokens and a round trip that the 3-second timeout can cut off — a slow provider means a quiet assistant. And the verification so far is three focused tests against a mocked fetch, not a live-provider run; the numbers above are the design's claims, not a benchmark.

Tell me I'm wrong: is a model writing its own progress updates a feature, or a lie generator with a 3-second budget? Would you trust a template that can never lie, even if it can never say anything useful either — or is one honest sentence, or silence, the right line?

— Krish Verma, creator of Ankita AI

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.