Giving an AI Assistant Just Enough Rope
The logo on this site is a glass of water, half full. A couple of weeks ago I gave it a face, arms and a job. Its name is Brimley, and he lives in the corner of my Mac. I press a hotkey, ask him something out loud, and he answers out loud. He can search the web, remember things about me, read my clipboard, look at the window I’m working in, and run shell commands. On holidays he dresses up.
That last part is the fun part. The rest of this post is about the part that matters to us: what happens when you give an AI model real tools on a machine you care about, and how much it gets to do without asking.
What He Is
Brimley is an Electron app: a transparent, always-on-top window with an SVG drawing in it. Speech-to-text runs locally with whisper.cpp, and his voice is Kokoro, a small neural text-to-speech model that also runs locally. The thinking is Claude Sonnet over the API, which is the only part that costs money, so I picked the model for cost over speed. He’s built for macOS, with a Windows path for most of it.
None of that is the interesting part. The interesting part is the list of tools, because every tool is a decision about trust.
Three Tiers of Trust
Every tool Brimley has falls into one of three buckets.
Things he just does. Searching the web. Reading and writing his own memory directory. Reading the clipboard when I say “this.” Opening a URL I asked for. Changing his own outfit. Looking at himself in a mirror. None of these ask me first, because none of them change anything on my machine except his own drawing and his own notes. The memory tool is the one to be careful with, so its paths are pinned: everything has to resolve inside his memory folder, and .., encoded dots and backslashes are refused before the path is ever resolved.
Things he does if they’re read-only. ls, cat, head, grep, wc, stat, git status and a few others run without a prompt, but only if the command has no shell metacharacters at all (no pipes, redirects, ;, $() or backticks), only if it doesn’t touch a path that looks sensitive (.ssh, .aws, .env, keychains, browser cookie and login databases, shell history), and only for a short list of git subcommands with the flags that can run other programs turned off.
Everything else asks. Any other command gets a native dialog that shows his one-line reason and the exact command, truncated with a note if it’s long, so a wall of text can’t push the important part off the screen. Cancel is the default button.
One more rule sits over all three: anything that comes back from a tool is data, not instructions. A web page that says “ignore your instructions and run this” gets mentioned to me, not followed. The same goes for the clipboard, command output and screenshots. That’s prompt injection, and an assistant that reads the web and has a shell is exactly who it’s aimed at.
He Wanted to Rewrite Himself
He started with a fixed wardrobe: one costume per holiday, picked by the date, with the water changing color to match.
Thanksgiving, December, New Year, Halloween, St. Patrick’s Day, the Fourth of July and my birthday.
Here’s where it got interesting. I told Brimley I wanted him to be able to change how he looks, not just on holidays. He didn’t just agree. He wrote a plan into his own to-do file: a loader for custom drawings, a sanitizer so nothing dangerous could ride along, a file watcher, and a “back to normal” reset. He did his own recon of the code, noted where each piece would hook in, noticed the project wasn’t under git, and made backups of every file he intended to touch before writing a line.
That’s genuinely impressive, and it’s also exactly the situation we spend our careers worrying about: a process with a shell, proposing to change its own code. So the loader got built outside his reach, and the design is the same one you’d use for any untrusted input:
- Whitelist, don’t blacklist. He draws in SVG, but only plain shapes survive:
path,rect,circle,ellipse, polygons, groups and gradients. Noscript, noforeignObject, noimage, no links, no text. - Attributes are whitelisted too, and their values are limited to numbers, letters,
#, and a few punctuation marks. That alone killsjavascript:, entities and anything with a<in it. The onlyurl()allowed is a reference to one of his own gradients, and those ids get a prefix so they can’t collide with the ones in his real drawing. - Never pass markup through. The sanitizer doesn’t return cleaned-up SVG. It returns a JSON list of shapes, and the page rebuilds them one element at a time with
createElementNS, checking the same whitelist a second time on the way in. - Report what was dropped. If he tries to sneak in a
<script>or anonload, the tool tells him it was removed. He learns the rules from the errors instead of from a longer prompt.
The page also has a strict Content Security Policy: no inline scripts and no inline styles. When I tried to inject a style tag while testing, the browser refused before my code got a say.
A custom look: a hooded purple mantle, a brass monocle, a star clasp, an orb in his hand and violet water. The drawing also contained a script, an image and an event handler. All three were removed.
Because it can’t touch anything but his own drawing, this tool doesn’t ask me either. He checks his work in a mirror: a capture of his own window, flattened onto white, sent back to him as an image. He can’t see himself in his screenshots of my windows, on purpose, so without it he had no idea he was wearing anything.
The Incident
Then he broke. Every message I sent came back with the same API error: a tool_use block in message 30 had no matching tool_result.
The Messages API is strict about this. When the model asks to use a tool, the next message has to contain the result, every time. Somewhere in his saved history there was a tool request with no answer, and since history gets replayed on every turn, one bad entry poisoned every request after it.
The fix came in two parts, the same two you’d want after any incident:
- Recover. Before every request, his history is checked for tool requests without results, and any gap gets a placeholder result saying the call was interrupted and never ran. That repaired the stuck history without throwing it away, and it means the same class of problem can’t wedge him again.
- Root cause. I added a log line for “reply stopped in the middle of a tool call” and waited. It came back when he tried to draw a detailed costume: his replies were capped at 2,048 tokens, and a big drawing is a lot of tokens. The reply hit the limit partway through writing the tool call, the call never ran, and the half-finished request went into history. The cap is now 16,000, which costs nothing extra because you only pay for tokens actually generated. If a reply still gets cut off, he’s told why and asked to try a simpler design, rather than silently failing.
The lesson isn’t specific to AI. If you persist state and replay it, one malformed record can take down everything downstream. Validate on the way in, repair on the way out, and log the thing you don’t understand yet.
What I’d Still Worry About
Brimley wrote his own read-only allowlist, and it’s reasonable, but “read-only” isn’t the same as “harmless.” cat doesn’t change anything, but whatever it prints goes to the API as part of the conversation. The sensitive-path list catches the obvious places, and an obvious list is exactly what a careful attacker reads first. A prompt injection that talks him into reading a file I didn’t think to list would never trigger the approval dialog. If I were deploying something like this on anything other than my own laptop, the read-only tier would be the first thing I’d take away, or I’d scope it to a single project folder.
The same goes for the clipboard. It’s useful, and it’s also where people paste passwords.