Skip to content
Permissions

Permissions

Ulmi controls which tool calls the agent may execute through a small multi-level permission system. The decision for every tool call is one of three levels.

LevelBehaviour
allowThe tool runs without confirmation.
askThe TUI shows a confirmation dialog. The model receives a denied result if the user rejects. In non-interactive mode (ulmi run) ask denies by default.
denyThe tool is blocked and the model receives permission denied so it can adapt.

The evaluator lives in internal/permission/permission.go. The TUI plugs it in via App.WithPermissionEvaluator.

Priority chain

For every tool call Ulmi walks these sources, highest priority first:

  1. Session mode hard-gate — in /plan or /ask mode, mutating tools (write, edit, delete, patch, bash, task) are always denied. Allow rules cannot override this.
  2. Pattern rules — permissions.rules from config. The first rule whose pattern matches the tool name or the call’s subject (the file path for filesystem tools, the command for bash) wins.
  3. Agent overrides — the tools map of the active agent (agents.<name>.tools.bash: ask). Useful for restricting an otherwise permissive agent. Applied on agent switch in the TUI.
  4. Preset — permissions.preset:
    • manual (default) — no baseline change
    • accept_edits — auto-allow file mutations (write/edit/delete/patch)
    • dont_ask — treat ask as deny (no prompts)
  5. Global per-tool / MCP / category — permissions.tools.<name>, then mcp.<server>.permissions (short name or "*"), then category fallbacks permissions.bash (bash only) and permissions.edit (write/edit/delete/patch only).
  6. Hardcoded default — bash, webfetch, websearch, write, edit, delete, and patch default to ask; everything else defaults to allow.
  7. Session grants — if the result is still ask and an in-memory Always-session pattern matches, the call is allowed. Grants never override deny or the hard-gate.

The first source that produces a decision short-circuits the rest (except dont_ask, which remaps a final ask to deny, and session grants, which only remap a final ask to allow).

Edit the live policy with /permissions in the TUI (alias /perms).

Configuration

permissions:
  edit: ask          # category fallback for write/edit/delete/patch
  bash: ask          # category fallback for bash
  preset: manual     # manual | accept_edits | dont_ask
  default_mode: build  # build | plan | ask — initial TUI session mode (`agent` is a legacy alias for `build`)

  # Per-tool levels (win over edit/bash categories).
  tools:
    read: allow
    glob: allow
    grep: allow
    list: allow
    write: ask
    edit: ask
    delete: ask
    patch: ask
    bash: ask
    webfetch: ask
    websearch: ask
    question: allow
    task: allow

  rules:
    # Allow editing Go files anywhere in the repo.
    - pattern: "**/*.go"
      edit: allow

    # Block reading/editing secrets.
    - pattern: "*.env"
      tools:
        read: deny
        edit: deny
        write: deny

    # Block edits and shell commands targeting system paths.
    - pattern: "/etc/**"
      edit: deny
      bash: deny

    # Block specific destructive shell commands.
    - pattern: "rm -rf"
      bash: deny
    - pattern: "sudo *"
      bash: deny

Built-in defaults allow read-only tools (read, glob, grep, list, …), question, and the task tool (sub-agents). Mutations, shell, webfetch, and websearch still ask. In /plan and /ask modes task remains hard-denied, but webfetch / websearch / question stay available for research (still subject to their permission levels).

Mutating file tools (write, edit, delete, patch) also refuse paths outside the workspace, even when the permission level is allow. Absolute paths that resolve outside the project root, .. escapes, and symlinks that point outside are rejected with path … is outside workspace …. Read-only tools do not apply this confine: they may still read absolute paths the user or model names. See Tools.

Subjects used for pattern rules and Always-allow grants:

ToolSubject
bashcommand string
filesystem toolsfile path
webfetchURL
websearchquery string

MCP tool levels live under the server config (short names), not under permissions.tools:

mcp:
  github:
    permissions:
      "*": ask
      create_issue: ask
      list_issues: allow

See MCP. permissions.tools.mcp__… still works as an override if you need a one-off qualified-name entry. Canonical MCP tool names are mcp__<server>__<tool> — not <server>:.

Pattern matching

The matcher in internal/permission/matcher.go supports several styles, tried in order:

  1. Exact equality (pattern == subject).
  2. Standard filepath.Match glob (*.go, ?.md). The pattern is also tested against the file’s basename for paths.
  3. Recursive double-star glob (internal/**/*.go, **/*.json).
  4. Shell-style glob where * matches anything including spaces and slashes — useful for command patterns like rm * or git push --force*.
  5. Plain prefix match — rm -rf matches rm -rf /tmp/foo.

This means you can write rules in whichever style is most natural for the case at hand.

Bash allow patterns use the whole command, without the file-basename fallback. A literal prefix must end at an argument boundary: git status does not allow git status-other. Bash allow rules and session grants only approve simple commands. Shell operators, substitutions, redirections, backslashes, comments, control characters other than tabs, and unbalanced quotes require confirmation. This is intentionally conservative: even a quoted literal such as echo 'a;b' requires confirmation. Balanced quotes around ordinary arguments remain supported.

A matching Bash allow rule becomes ask for these complex commands (deny with dont_ask); existing deny rules and read-only modes still apply. Explicit unrestricted tool/category or agent-level bash: allow remains unrestricted. These patterns are convenience grants, not an OS sandbox or a guarantee that an allowed executable and its arguments are harmless.

Per-agent tool overrides

User-defined agents can ship their own permission policy in their YAML frontmatter:

---
name: safe-reviewer
description: "Code-review agent with no shell access"
tools: [read, glob, grep, list]
permissions:
  bash: deny
  edit: deny
  tools:
    read: allow
---

You are a code reviewer …

The same shape works in the project config under agents.<name>.tools and agents.<name>.permissions if you prefer to keep all configuration in YAML.

Built-in agent policies

AgentbasheditAllowed tools
buildaskask (hardcoded default)All registered tools
plandenydenyread, glob, grep, list, webfetch, websearch, question
askdenydenysame as plan

Built-in policies are defined in internal/agent/builtin.go.

How the TUI handles ask

When a streaming response asks for one or more tool calls:

  1. Each call is evaluated.
  2. allow calls are queued for execution.
  3. deny calls are recorded as failed results immediately.
  4. ask calls go into a queue; the confirmation overlay walks them sequentially.
  5. Once the queue is empty, all approved calls run in parallel (capped at 10 concurrent executions). Results are sent back to the model.

This batching means a single response that calls multiple tools only prompts you for the ones that need confirmation.

Always allow

The confirmation dialog offers four outcomes when a safe pattern can be derived from the tool call:

KeyAction
yAllow this call only
aAlways allow matching calls for the rest of this session
AAlways global — allow and prepend a rule to the global config
n / EscDeny

The dialog shows Will remember: <pattern> for the suggested rule. Bash patterns use a safe command prefix (sleep 15 → sleep *, git status --porcelain → git status *). File tools use an extension glob (internal/tui/app.go → **/*.go).

Dangerous prefixes (rm, sudo, curl, …) still offer Always session but hide Always global — persist those only via /permissions.

Complex shell commands do not offer Always allow. The same restriction applies when matching previously saved rules or session grants, so an existing git status * grant does not allow an appended shell command or command substitution. Ambiguous executable/subcommand tokens containing glob characters do not produce suggested grants. Empty executable/subcommand tokens also do not produce grants. Bash parsing preserves empty quoted arguments and treats only ASCII spaces and tabs as word separators, so Unicode spaces cannot change the remembered command.

Session grants only suppress ask; they never override the /plan//ask hard-gate or an explicit deny rule. Saved rules are prepended to permissions.rules and written with config.SavePermissions (global ~/.config/ulmi/config.yaml).

Non-interactive mode

ulmi run evaluates every built-in tool call using the configured policy. allow executes the call; ask and deny return a denied tool result without prompting. Multi-file reads and patches check every target path before execution, including write/edit path aliases. Read-only agents and modes cannot mutate files even if a rule would otherwise allow it.

For example, to allow file creation and editing in CI:

permissions:
  tools:
    write: allow
    edit: allow

Use per-tool entries: the generated config’s permissions.tools settings have precedence over category fallbacks such as permissions.edit or permissions.bash. Shell execution requires its own tools.bash: allow or a matching Bash rule; allowing file edits does not allow shell commands.

Subject extraction

The TUI extracts the subject of a tool call from its arguments before evaluation via permission.ExtractSubject:

  • bash → command
  • webfetch → url
  • websearch → query
  • otherwise → path, or paths for multi-file read

That is what allows pattern: "**/*.go" to gate file mutations and pattern: "rm -rf" to gate shell commands. Implementation: internal/permission/checker.go.