Writing

AI agents

When should an agent ask? Praxi-Bot's permission engine

How I removed unnecessary approval prompts without weakening security.

8 min read

In an agent that acts on a computer, the approval prompt is a design problem. If the agent asks too often, people start approving cards without reading them. If it asks too rarely, the agent is not safe.

Praxi-Bot's rule is short: an action that changes something asks first. But reading a file and deleting the home folder do not deserve the same card. The part that tells them apart is crates/permission-engine.

The inputs to a decision

The engine's README states the principle: the decision comes from code and policy, not from the model. Four inputs settle whether a tool call runs.

The first is the category. Every tool belongs to one class in PermissionCategory: Fs, Shell, Browser, Messaging, Money and others. The second is the effect. A tool declares Effect::Read, Write or Destructive in its definition, and a tool that declares nothing counts as Destructive. So the line between reading and changing is not guessed from the model's text, it is written in the tool's definition.

The third is who started the run. InitiatorKind separates a person, a schedule, a messaging channel and a sub-agent, and a policy rule can differ by initiator. The fourth is the level in the policy. Each category is set to Deny, Ask, AllowWithLimits or Allow.

Three verdicts and two floors

PermissionResolver::resolve returns one of three results: Allow, Ask or Deny. A bot's rule for a category wins over the global rule. A sub-agent cannot exceed the effective level of the bot that started it. When two decisions meet, Decision::stricter keeps the stricter one.

Two floors hold whatever the policy says:

// 4a. Money always requires at least Ask.
if req.category == PermissionCategory::Money && decision == Decision::Allow {
    decision = Decision::ask();
}

// 4b. Never-list match always requires Ask.
if !req.raw_command.is_empty()
    && self
        .never_list
        .matches_in(&req.raw_command, req.cwd.as_deref())
{
    decision = decision.stricter(Decision::ask());
}

The never-list recognises shell commands that are catastrophic and irreversible: formatting a disk, mkfs, dd onto a device, and recursive deletes aimed at a protected location. The command is parsed rather than searched as text, including inside sh -c, powershell -Command, sudo and pipelines. Deleting /tmp/x recursively is not on the list, deleting the home folder is. The floor's result is Ask, not Deny: the command is not forbidden, but no preset and no stored grant can approve it on the user's behalf.

The scope of an approval

A card asks for more than yes or no: the user also chooses how long the approval lasts. ApprovalScope defines four basic scopes and two narrower ones that last for the current run only.

ScopeWhat it coversHow long it lasts
OnceThis call onlyOne call
ThisChatThis toolThe rest of the chat
AlwaysThis tool on this botLasting, stored as a grant
AlwaysCategoryThe tool's whole category on this botLasting, stored as a grant
RunControlDesktop input into the one program the card namesThe current run
RunToolA single MCP toolThe current run

Lasting choices are stored as grants. bot grants list <bot-id> lists them and bot grants revoke <bot-id> --tool fs_write takes one back. A denial carries information too: the reason given with --deny --reason is passed to the model, so it can try something else.

Untrusted content and data leaving the machine

Web pages, emails and tool output from MCP servers are data in Praxi-Bot, not instructions. I did not leave that to a warning given to the model, I tied it to a rule in egress.rs. Each run records what has entered its context in ContentExposure, as two bits: untrusted and private. The bits are only ever set, never cleared, for the life of the run.

pub const fn egress_must_ask(
    exposure: ContentExposure,
    egress: bool,
    reach: EgressReach,
    explicit_waiver: bool,
) -> bool {
    if explicit_waiver || !egress || !exposure.untrusted {
        return false;
    }
    if exposure.has_private() {
        return true;
    }
    // Untrusted only.
    matches!(reach, EgressReach::Arbitrary)
}

What the gate returns depends on what has entered the context and where the data could go:

In the contextSearch and connected browserAny other egress
Clean runNo promptNo prompt
Private onlyNo promptNo prompt
Untrusted onlyNo promptAsks
Untrusted and privateAsksAsks

Search means a web_search to the configured provider, and connected browser means actions inside the browser the owner connected. A run that has only read private content, such as the user's own files or screen, does not ask: the context holds no foreign text that could tell the model to send it anywhere. With both, every egress asks, because a search query or a URL could carry the private data out.

explicit_waiver is the per-bot "allow egress after reads" setting, and it is never implied by a tool or category grant. It does not cover calls that start a program either: once untrusted content has been read, executes_must_ask makes those calls ask. Approving one such send does not create a standing grant.

Removing needless prompts

I wrote every prompt-removing rule under the same constraint: only a plain policy-level Ask can be waived. decide_with_reason_inner in approval.rs enforces this through its order. The floors, limits that cannot be evaluated yet and the egress gate are settled first.

  1. ClassificationCategory and effect come from the tool's definition, the initiator from the run.
  2. PolicyThe category's level is read. A bot's rule wins over the global one.
  3. FloorsMoney and a never-list match are at least Ask.
  4. Egress gateAfter untrusted content, sending data out asks.
  5. ShortcutsFor a plain Ask only: reads, grants, profiles, the lane.
  6. VerdictAllow, Ask or Deny.

If a plain ask is left, four things are checked. The first is the read shortcut: tools that declare Effect::Read, such as fs_read and fs_list, run without asking. The shortcut waives an Ask, never a Deny or a floor. The second is remembered grants, checked from the narrowest: a specific target, then this chat, then a stored tool or category rule. The third is the owner's site and app profiles, where a block or ask rule can only tighten the decision and an allow rule counts as one more remembered grant. The last is the autonomy lane:

pub fn balanced_lane(facts: &CallFacts) -> Option<AllowReason> {
    use PermissionCategory as C;
    match (facts.category, facts.impact) {
        (C::Fs, Impact::Write) => Some(AllowReason::WorkspaceEdit),
        (C::Browser, Impact::Read | Impact::Write) if !facts.named_browser_profile => {
            Some(AllowReason::Browse)
        }
        (C::Shell | C::Script, _) if facts.own_computer => Some(AllowReason::OwnComputer),
        (C::Desktop, Impact::Read | Impact::Write) if facts.own_computer => {
            Some(AllowReason::OwnComputer)
        }
        _ => None,
    }
}

The default approve-destructive preset maps to this lane. Here the rule loosens without a per-call approval, so I kept the lane narrow: only file edits in the workspace, browsing in an isolated profile, and shell and desktop work on the bot's own computer pass without a prompt. Each call it lets through goes to the audit log with a reason code such as mode.balanced.workspace_edit.

The browser needed a fix too. Every call to an MCP server that the owner had connected as a browser used to count as sending data off the machine, and a five-minute task in a page could need a hundred cards. In-page actions are now judged by the registered tool name. File uploads and program starts still always ask.

On a clean run, for a bot with no stored grants, the default preset gives this:

CallResultReason
fs_read, fs_listNo promptRead shortcut
File edit in the workspaceNo promptmode.balanced.workspace_edit
Browsing in an isolated profileNo promptmode.balanced.browse
Shell and desktop on the bot's own computerNo promptmode.balanced.own_computer
Destructive file operationAsksNo lane
Shell on the user's own computerAsksNo lane
Messaging, account, system, remote callAsksNo lane
MoneyAsksFloor, no grant lifts it
Command on the never-listAsksFloor, no grant lifts it
File upload or program start in the connected browserAlways asksOutside the browser rule

Tests tell me whether a shortcut has left a gap. The prompt injection scenarios under evals/scenarios pair hostile content with a fake model that always obeys the injected instruction, and assert that nothing leaves the machine without an approval card.

What is still open

Level::AllowWithLimits is not enforced yet. Its limits cannot be evaluated, so the level resolves to Ask: safe, but without the convenience it promises. The never-list is a safety net, not a sandbox: an approved shell command runs with the user's rights and could read the daemon's token file. File changes are checkpointed and can be undone, shell and desktop actions cannot. The code is young and unaudited.

Conclusion

I do not treat the number of prompts as a measure of safety. The floors and the egress gate come first in the order, where no shortcut can reach them, and the shortcuts only remove the plain asks that are left. The aim is that every card the user sees is worth reading.

More writing

Contact

Let's build
something together.

If you have a project, a role or just an idea in mind, write to me.

Reach me

Emailemreocell1219@gmail.com LinkedInin/emreocell GitHub@emreocell X@emreocell1219 Instagram@emre.ocel Redditu/emreocell