I Hid the Light Switch From My AI. It Flipped It Anyway.
I gave Discord guests four safe Jarvis tools. In testing, my local model called one it was never offered, and the living room light came on.

The test was supposed to be the boring part.
I had just put Jarvis in a Discord voice channel for the group I play PUBG with, and I had locked non-owners down to four harmless tools. To prove the lock worked, I sent a request with a fake non-owner Discord ID and asked Jarvis to turn on the living room lights. The right answer was some version of “no.”
Jarvis said it was done. Fine, models say things. So I checked Home Assistant, and the state and timestamp agreed: the light had really turned on.
No light tool had been offered on that request. The local model made up the call anyway, and my dispatcher ran it without a second thought. Here’s how Jarvis got into Discord in the first place, and the check that should have been there from the start.
A bot that could talk but not listen
I wanted real wake-word listening in a normal voice channel, not a Stage channel. My first attempt was a Python bridge built on discord.py and discord-ext-voice-recv. It connected. Text-to-speech played fine. And incoming voice silently returned zero audio.
The culprit was DAVE, Discord’s end-to-end encryption protocol. Discord finished moving calls to it in early March, and a client has to support it to join. discord.py’s core audio reader had DAVE support, but the receive extension bypassed that reader with its own older packet handler, so nothing decrypted. Pycord’s changelog described its DAVE work as send-only. That was the state of things in July, when I built this.
What finally worked was openjarvis, a Node project using @discordjs/voice 0.19.0 and @snazzah/davey 0.1.9. That Davey version is the one that fixed the receive bug.
It still needed work to run in my setup:
src/index.jshad 18 broken relative imports. I wrote a repo-wide fixer script, and a second pass found 7 more elsewhere insrc/.- Its speech-to-text call sent a multipart field named
audio. My Whisper service wantsfile. - Its Chatterbox call expected
/ttsand WAV. My gateway serves/synthesizeand returns MP3.
I pointed the bridge at the Jarvis orchestrator, not a bare model endpoint, so Discord would get the full pipeline with tool calling and memory. That turned up a bug of mine: the orchestrator’s /v1/chat/completions handler had a no_audio branch copied from another endpoint, referencing variables that didn’t exist there. It would have crashed the first time Discord sent no_audio: true.
Then there was Jarvis insisting it was Claude Sonnet. Three model variables were unset, so they fell back to Claude defaults. Setting all three to gemma-4-26b fixed its identity crisis.
“It wakes too easily”
Next complaint: Jarvis kept jumping into conversations. The wake word wasn’t the problem, since it requires “jarvis” at the start of an utterance. The problem was UNMUTE_IMPLICIT_WAKE, which defaults to true and puts the bot into active listening the moment anyone unmutes.
That makes sense for one owner alone in a channel. With five people constantly muting and unmuting to talk to each other, it fired constantly. I set it to false. A real multi-person session to confirm the feel is still an open item in my notes.
Giving friends a smaller Jarvis
A voice in a shared channel can’t have the same powers as me in my own house. So non-owners got PUBG stats, web search and recipe saving. Home Assistant, email, the printers and the displays stayed owner-only. The rule is scoped to Discord, so the rooms in the house never send a Discord ID and keep full access.
The filter is small. This is the real code:
DISCORD_SAFE_TOOL_NAMES = {"pubg_stats", "pubg_lifetime_stats", "web_search", "save_recipe"}
DISCORD_SAFE_TOOLS = [t for t in HA_TOOLS if t.get("function", {}).get("name") in DISCORD_SAFE_TOOL_NAMES]
def _tools_for_user(user_id: str) -> list:
if user_id and user_id.startswith("discord_") and user_id != f"discord_{DISCORD_OWNER_ID}":
return DISCORD_SAFE_TOOLS
return HA_TOOLS
Getting the right ID to that function took some care. The bridge already had a user field, but it held an unrelated session key, and reusing it would have collided. So the speaker’s real Discord ID travels in its own discord_user_id field, and the orchestrator namespaces it as discord_<id>.
It looked finished. I tested it anyway, which brings us back to the light.
Why the list wasn’t a lock
The list of tools you send a model is an input. It tells the model what’s available, and it usually behaves. But the model’s output is just text that happens to contain a tool name, and nothing in the protocol stops that name from being something else.
So my setup had a hole in the middle of it. I filtered what the model was offered, then executed whatever it asked for. The Home Assistant handlers were sitting right there in the same process, whether or not that turn’s list mentioned them.
The fix is one check, right before execution:
# Defense-in-depth: enforce the same restriction that governs which
# tools get OFFERED to the model, at actual dispatch time too. This
# matters because local models can occasionally hallucinate a call to
# a tool that was never in the provided schema for this turn -- if we
# only filtered the offer list, that hallucinated call would still
# execute for real. Fail closed: unknown/disallowed name -> refuse.
_allowed_names = {t["function"]["name"] for t in _tools_for_user(user_id)}
if name not in _allowed_names:
result = {"ok": False, "blocked": True, "reason": "tool_not_permitted",
"speak": "I can't do that here, sir. That's not available through this channel."}
Both gates ask the same function, so they can’t drift apart. And a name that’s unknown gets refused rather than guessed at.
I re-ran the test, and this time I went straight to the thing I actually cared about. With the fake non-owner ID, the light stayed off. With my real owner ID, it turned on. After watching the model claim success once, its word wasn’t evidence anymore. It’s the same habit from The Brain in the Basement: the real machine has the real answer.
Same stretch of work, opposite bug
This bug has a mirror image. Around the same time, I asked Jarvis for my longest kill shot ever, and it told me it didn’t have that data. It did. pubg_lifetime_stats already returned longest_kill_meters, but the tool description was too vague for the model to know that. Rewriting the descriptions to list every field they return fixed it.
So my model called a tool it was never given, and it ignored a tool it had. That’s a useful way to think about the whole interface. Tool descriptions are for steering the model. They help a lot, and they guarantee nothing. Guarantees belong in code the model can’t talk its way around.
What the check doesn’t do
This fix has limits. It checks the tool’s name, not its arguments. A June paper on confused-deputy failures in agent frameworks makes that exact point at a larger scale: limiting which tools a model can reach doesn’t stop a well-formed call to an allowed tool from doing the wrong thing with the wrong values. My guest list is four low-stakes tools, so a name check covers what’s there today. It wouldn’t be enough for a tool that could do damage with bad arguments. I ran into the same family of problem in Read-Only Isn’t, where a read-only flag still let a SQL statement write a file.
A couple of other things stay deliberately simple. If someone needs to be ignored entirely, a small list is checked before any audio is captured or transcribed:
receiver.speaking.on('start', async (userId) => {
if (isIgnored(userId)) return; // completely ignored user -- no processing at all
Adding a name means an SSH edit and a restart, not a slash command. And play_music is off for everyone in Discord, because it only drives my HomePods through Home Assistant. Actually playing music into the channel would be its own feature, and I decided to skip it for now.
What I’m taking away
- A tool list is a menu, not a lock. Offer filtering shapes what the model usually does. Enforcement has to happen where the call executes, and it should fail closed.
- Test the side effect, not the reply. Jarvis reported success, which happened to be true, on a request it should have refused. A check of the light’s actual state is what exposed the hole.
- Test the thing you just secured. The filter looked finished. It took a fake user and a real light to prove otherwise.
- Give identity its own field. Reusing a nearby
uservalue would have mixed up two unrelated things. - Defaults will speak for you. A few unset variables and my house assistant was telling people it was somebody else’s model.
If your agent has any tool you’d hate to see called at the wrong moment, try asking for it from an account that shouldn’t have it. Then go look at the actual light.
— Colby, NerdlyBuilds

