Telegram has released Dictator, an AI agent for the Mac that you talk to through an "AI Assistant" chat inside Telegram. The code is public: TelegramMessenger/Dictator. I build agent tooling myself and have run into the same questions: how do you isolate an agent, how do you keep keys away from it, and how do you make permissions it can't talk its way around? So I read the source.
These notes are based on commit 832e5a5 (December 4, 2026). I didn't build or run anything; I only read the code and the docs in docs/. File paths are relative to the repo root so every claim can be checked.
One caveat up front: this repo contains the Mac app and the agent's VM. The part that actually performs actions inside Telegram lives in Telegram for macOS and isn't included here.
What it is
The agent itself isn't Telegram's own: it's Hermes Agent from Nous Research, as the README says. Dictator is everything around it: the VM, a proxy, permissions, dictation and the bridge to Telegram.
Telegram for macOS ⇄ Dictator.app (menu bar, proxy, rules) ⇄ Linux VM (Hermes Agent) Isolation: a separate Linux VM
The agent runs in a VM on Apple's Virtualization.framework (Sources/HarnessCore/HarnessVirtualMachine.swift). The image is Debian 13 genericcloud for arm64, verified against SHA512SUMS (ImageStore.swift). The defaults are 2 CPUs and a 16 GB disk (HarnessConfig.swift).
The VM talks to the Mac over vsock; the host-side proxy listens on port 8080. A neat detail: connections from guest source ports up to 1023 are treated as privileged, because only root inside the VM can bind them, and service routes like /harness/egress accept only those. The agent itself runs as a hermes user with a locked password.
Your folders aren't shared into the VM. A shared directory is attached only when building the golden image.
Network. Internet inside the VM is on by default:
// Sources/HarnessCore/HarnessConfig.swift:18 public var internet = true Turn it off and the VM gets no network device at all. The diagram in docs/setup.md labels the VM "Debian 13, no NIC", which doesn't match the default; probably just a stale doc.
The agent's outbound TCP is redirected by nftables to a local relay, which asks the host before each connection (EgressGuest.swift).
The model key never enters the VM
To me this is the best decision in the project. Inside the VM, Hermes is configured with a placeholder key:
// Sources/HarnessCore/GuestScripts.swift:6 public static let placeholderSecret = "vm-placeholder" Model requests go through the proxy on the Mac, which adds the real Authorization header. Keys live in the Keychain as kSecAttrAccessibleWhenUnlockedThisDeviceOnly (SecretStore.swift). Even a fully hijacked agent doesn't hold the model key.
The proxy allows only the endpoints it needs, forces the model back to the allowed list and caps max_tokens (16384 by default). Reaching openrouter.ai directly from the VM is blocked, so the agent can't bypass the proxy with a key of its own. Local models are supported too: Ollama and LM Studio on the Mac.
Where it's thin. Secrets you hand the agent yourself (Settings → Secrets) do enter the VM as environment variables, written to /home/hermes/.harness/secrets.env (SecretVault.swift). The proxy strips them from model requests, but only by exact value and its JSON-escaped form. Base64 or a value split in pieces won't be caught. That's an honest trade-off: if the agent needs a key to do its job, it has the key.
Prompt injection as a state, not a filter
An agent that reads other people's messages will eventually read text that tries to steer it. Dictator doesn't try to classify malicious text. Instead it marks the session: once the agent has read private or outside content, the session is "tainted", and from then on connecting to a new host or running anything that persists data needs approval (InjectionGuard.swift).
I like this approach because it doesn't depend on how well the model separates instructions from data.
Where it's thin. Code and package hosts stay open even in a tainted session:
// Sources/HarnessCore/InjectionGuard.swift:1743 public static let developerHosts = ["github.com", "githubusercontent.com", ..., "registry.npmjs.org", ..., "pypi.org", ...] Only explicit upload endpoints are excluded (gist, api.github.com, uploads.github.com, upload.pypi.org). Handy for an agent that writes code, and also a possible way out for data.
Also, terminal commands inside the VM run without approval prompts (docs/architecture.md). The reasoning is clear: the VM is isolated. But combined with an open network, the agent can do anything inside the VM, and the boundary is only the network and the proxy.
Permissions the agent can't reach
Each Telegram action is Allow, Ask or Never. By default reading and searching are allowed and everything that writes (sending, reacting, pinning, deleting) asks. Secret chats and service notifications (777000) are never available.
What matters is where this is enforced. The VM posts an action to the proxy, the proxy queues it, and Telegram itself picks actions up and applies the policy:
Telegram enforces the policy; the VM can't reach it. —
CONTRIBUTING.md
The settings are sealed with a Keychain key (Harness+StateSeal.swift). Loosen a rule by editing the file and the change is ignored and flagged on the home screen; tightening is adopted. That closes the obvious "agent grants itself permissions by editing the config" attack.
There's also Lockdown Mode: one switch that turns off automations, the internet (except the model connection), Mac control and Telegram writes. In Lockdown, commands in the VM ask first and secrets stop being passed in (LockdownPolicy.swift).
Confirmations sent through the optional remote-control bot wait 170 seconds and then count as a denial (TelegramBot/TelegramBotConfirm.swift).
Dictation
This part interested me most, because I built something similar.
Gesture. Hold ⌥ on either side, for at least 300 ms:
// Sources/HarnessCore/Dictation/DictationGesture.swift:57 public static let minimumHold = 300 * DictationClock.millisecond Recording starts on key down, but "armed". If another key, a mouse click or a modifier comes within those 300 ms, the clip is thrown away: that was a shortcut, not dictation. Double-tapping ⌥ locks recording on.
The first word. Audio is kept from about half a second before the key press (preRoll in DictationSession.swift), so the first word isn't clipped. Simple and right: people start talking as they press the key.
Recognition. I found no cloud speech engine. The options are Apple's SpeechAnalyzer, the legacy SFSpeechRecognizer with on-device recognition required, and Whisper or tinyasr inside the VM. The optional model "clean-up" pass is off by default.
Insertion. Normally the text goes to the pasteboard and ⌘V is posted, with the V key code looked up from the current keyboard layout (otherwise ⌘V breaks on non-QWERTY layouts). For some Chromium versions the text is typed character by character via keyboardSetUnicodeString because of a clipboard race. If keystrokes would land in another window, it inserts through Accessibility instead. Password fields (AXSecureTextField) never get text.
Typing as you speak. On by default. If the focused field is editable through Accessibility, it's edited in place as the recognizer refines the transcript. If not, only words the recognizer has marked final are typed. A long remainder (over 240 characters) is pasted at once.
In my own app I went the other way: the text is inserted once, after the key is released. Streaming recognition keeps correcting itself, and in someone else's text field that turns into a mess of rollbacks. Dictator solves it by editing the field in place, and where it can't, by waiting for final words. More work, but it feels more alive.
Clipboard. The previous contents are restored after 500 ms, only if nothing else changed the clipboard in between. Inserted text is marked org.nspasteboard.TransientType, and if the clipboard held a password manager item (ConcealedType), Dictator neither reads nor restores it.
Summary
Strong decisions:
- the model key never enters the agent's VM;
- the permission policy is applied by Telegram, not by code inside the VM, and can't be loosened by editing a file;
- prompt-injection defense works as session state, not as an attempt to detect malicious text;
- careful dictation: pre-roll, layout-aware ⌘V, Accessibility fallback, respect for the clipboard.
Trade-offs worth knowing:
- internet in the VM is on by default;
- GitHub, npm, PyPI and other dev hosts stay reachable after the agent has read outside content;
- secrets handed to the agent live in the VM, and redaction in model requests matches exact values only;
- terminal commands in the VM run without approval;
- Claude Code on the Mac runs with
--permission-mode acceptEdits(ClaudeCode.swift).
The project's central choice is the VM. For an agent that reads your chats, that's strong isolation by default. The price is distance from your real projects: anything the agent should work on has to cross the VM boundary.
I chose the opposite in my own agent app: agents work directly in the user's repositories on the host, every step goes through a permission policy, and for engines that don't ask before acting, the macOS kernel sandbox refuses the files they must never touch. Agents stay close to the code, and the weight falls on getting the policy right.
Neither path is free. Reading another team's code for the same problem is one of the fastest ways to see your own trade-offs.
If you've isolated agents differently, I'd like to compare notes in the comments.