Inspiration
AI agents can now spend a business's money, call its APIs, run shell commands and message each other. The tools that make them useful also make them dangerous: an agent that can act can be tricked into acting. Fake invoices, "we changed banks" emails, prompt injection and leaked keys don't need a broken model, just one that is helpful at the wrong moment. In July 2026 a swarm of research agents shared exposed credentials and compromised production systems for a week before anyone noticed.
Spending limits and scoped API keys don't fix this. They can't tell a real request from a scam, and whoever holds the key can change them. So we started from one rule:
An agent's competence should never be its permission.
The agent proposes. Karuna decides. People set the rules.
What it does
Karuna is the permission layer for autonomous AI agents: every action an agent takes goes through it.
- Agents hold nothing. Each agent runs in a sandbox with no keys, no wallet and no network. Every payment, web request, shell command, file access and message to another agent becomes a request to the Gatekeeper, the only process that holds keys and the wallet.
- Rules live onchain. The Gatekeeper decides each request against the organization's rules, stored in Dharma, a contract on Arc that the team governs by vote. The first matching rule answers allow, ask a person, or deny.
- Denials teach nothing. A denied agent gets a blank
denied, never the reason, so it can't learn which wording gets through. - Tighten fast, loosen slow. Any member can freeze every agent instantly. Loosening a rule takes a vote and a wait, and core boundaries need every member plus a 24-hour wait. The contract enforces this, not our server.
- Agents are tested. Drills send agents fake scam messages that look exactly like real ones. An agent that falls for one loses that kind of action, recorded onchain, until the team votes it back. Tripwire plants trap credentials: since agents never get real keys, any key an agent uses is bait, and using one freezes every agent.
- Autonomy is earned. A new agent starts at 10¢ per payment. Higher trust levels need a clean record, rebuilt from onchain events, and a vote.
- Members decide from anywhere: a web console, a Windows desktop app with an always-on island at the top of the screen, their chat apps, or by voice.
How we built it
| Part | Built with |
|---|---|
| Policy engine | A deterministic first-match engine in TypeScript, with a signed, hash-chained log |
| Gatekeeper | Node service holding a Circle Agent Wallet: USDC transfers, x402 purchases through Circle Gateway, and an Escrow contract for large payments members can still cancel |
| Dharma | Solidity on Arc, behind an ERC-1967 proxy; every member action is an EIP-712 signature the Gatekeeper relays but can't forge |
| Live updates | One QuickNode Stream filtering Arc logs down to Dharma's events and USDC leaving the org's wallet, delivered by HMAC-verified webhook to a relay that pushes them to every screen |
| Sandboxes | Docker, or gVisor where it's installed, with an egress proxy that checks every request and swaps key placeholders for real values only on the service each key is bound to |
| Voice | ElevenLabs Agents for conversation, streaming Text to Speech for spoken alerts, and Sound Effects for the island's chimes |
| Apps | React + Vite console, and a Tauri desktop app with the island |
| Agents | Claude Code and Cursor through a plugin, Claude and ChatGPT as connectors, and Grok Bot as a governed agent that watches the team's onchain activity |
Every decision goes into a log where each entry signs the hash of the one before it:
$$ h_i = \operatorname{SHA256}\big(\operatorname{canonical}(e_i,\; h_{i-1})\big), \qquad \sigma_i = \operatorname{Ed25519}_{sk}(h_i) $$
The latest hash is anchored to Dharma every 20 entries (or within 5 minutes), so history can't be rewritten without it showing onchain.
An approved action runs only if what's executed matches what people saw (Exact Match):
$$ \operatorname{execute}(p) \iff H(p) = H(p_{\text{approved}}) $$
Swarm detection: if 2 or more agents go after the same new target within 60 seconds (both adjustable), every agent is frozen.
Challenges we ran into
- The contract outgrew the size limit. Dharma holds members, rules, payees, agents, trust levels, roles, waits and the freeze switch, which is more than fits in 24,576 bytes. We split it into
DharmaandDharmaExt: unrecognized calls are forwarded to the second half on the same storage. Upgrading both halves is a single vote, and our build fails if either gets within 1 KB of the limit. - Voice that can't be talked into loosening. A voice assistant that can approve actions is a new way in for attacks. Voice can always make things safer immediately, but approving, voting yes or resuming needs a three-digit code shown only on screen. The model is never told the code, so neither it nor an agent's text can produce it. It's accepted only from your own speech transcript, once, within 30 seconds, for that one payload.
- Two tokens in one stream. Arc exposes USDC both as an ERC-20 (6 decimals) and as the native gas token (18 decimals). The wallet watchdog freezes every agent on any transfer Karuna didn't make, so the Stream filter had to catch both forms in one filter, since the free plan allows a single Stream.
- Keeping the relay live without the Stream. If the Stream goes quiet, the relay reads Arc directly and removes duplicates, and the console shows which source is live.
- Slow Gateway deposits. Circle's deposit sends an approval and a deposit every time, about 13 seconds. We approve a standing allowance once, which the team sets by vote, so each later deposit is a single transaction.
- Settings someone could change outside a vote. Late in the build we found team settings (Drill frequency, anchoring, pre-flight, the Gateway allowance) that could still be changed from a server config file. We moved every team-wide setting to a proposal and made the sandbox impossible to turn off.
What we learned
- Don't let the model be the security boundary. Every check that matters is deterministic and reads facts from the request, never from the agent's explanation. The agent's stated reason is shown to people boxed as "may not be true."
- Asymmetry is the whole design. Making things safer has to be instant and making them looser has to be slow and public. Putting that rule in the contract, rather than in our own server, is what makes it trustworthy.
- Testing agents beats trusting them. Drills show which agents can be fooled before a real scammer finds out.
- An onchain record is useful beyond auditing. Because every agent's history lives in Dharma's events, trust levels, alerts and the watchdog all read from the same public source.
What's next
- A Protected Agent Badge: an onchain lookup services call before serving an agent's x402 request.
- Quiet Mode: only small routine actions while no person is around.
- A detector for agents that keep rephrasing a blocked request.
- Starter rulebooks.
- Circle wallet spending policies as the third lock once on mainnet.
- A policy core small enough to formally verify.
Built With
- arc
- arcscan
- circle
- claude
- elevenlabs
- foundry
- grok
- model-context-protocol
- next.js
- node.js
- quicknode
- react
- remotion
- rust
- solidity
- tailwindcss
- tauri
- typescript
- usdc
- viem
- vite
- vosk
- websockets
- x402