#4844·deepagents

Approval policy file for fine-grained auto-approval rules

Author: NinaadRaoCreated Jul 18, 2026Updated Sep 28, 2026
Labelstype:featureorg:externalpriority:backlogpackage:dcode

Submission checklist

  • This is a feature request, not a bug report.
  • I searched existing issues and didn't find this feature.
  • I checked the docs and README for existing functionality.
  • This request applies to this repo (deepagents) and not an external package.

Area (Required)

  • deepagents (SDK)
  • dcode
  • talon
  • acp
  • evals
  • harbor
  • daytona
  • modal
  • quickjs
  • runloop
  • vercel
  • langsmith-sandbox
  • Other / not sure / general

Feature description

Add support for a project-scoped permissions file that grants or denies specific tool calls before the session-wide approval mode is consulted.

Today, dcode approval is all-or-nothing. The three modes (MANUAL, AUTO, YOLO in approval_mode.py) funnel into one predicate, _should_interrupt_tool_call (agent.py:1413), which only checks the session mode. It never looks at the tool call's arguments, so there's no way to express "auto-approve write_file/edit_file under src/**, but always confirm execute commands containing rm or git push." For --non-interactive runs in CI, the choice is between confirming everything (not viable) and --yolo (not acceptable).

The data a policy would match against is already available at the call site: ToolCallRequest.tool_call carries the tool name and args (target path for file tools, shell command for execute).

Example .deepagents/permissions.toml:

toml
[[rule]]
tool = "write_file"
path_glob = "{src,tests}/**"
decision = "approve"

[[rule]]
tool = "execute"
command_glob = "*rm -rf*"
decision = "deny"

Threat model: a malicious repo must not be able to grant itself silent approval just by being cloned and opened. The file should only be read after explicit, persisted user trust, like skills/trust.py does.

Proposed solution (optional)

New module permission_policy.py with a PermissionRule (tool, optional path_glob/command_glob, decision: approve|deny), a loader for .deepagents/permissions.toml that returns None unless the project is trusted, and a first-match-wins evaluator that returns None on no match so existing mode behavior is untouched.

  • "approve" wires into _should_interrupt_tool_call ahead of the mode check: a matching rule returns False (skip the interrupt) even in manual mode.
  • "deny" can't go through that predicate, since InterruptOnConfig.when only returns a bool (interrupt vs. auto-approve). Instead, a small wrap_tool_call middleware short-circuits with a rejection ToolMessage. Appending it via create_cli_agent's agent_middleware places it ahead of HumanInTheLoopMiddleware in the wrap chain, so no stack surgery is needed.
  • Trust mirrors the --trust-project-mcp threat model but not its plumbing (which threads a flag through ~9 files to cross the client/server boundary). A persisted boolean in ~/.deepagents/.state/ works here since both processes can read it locally. Grant it via a dcode permissions trust [path] subcommand; untrust/list are natural follow-ups.

Additional context (optional)

Distinct from #4804 (classifier-backed Auto): Auto is a per-call model judgment with no user-authored rules. This is deterministic and git-reviewable; a teammate can read permissions.toml in a PR diff and know exactly what autonomy the agent has.

Happy to implement this. The design above (loader/matcher, trust gate, hook point, tests) is scoped and ready to go once assigned.