Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tools and Policies

Duragent agents can use tools to interact with the outside world. A policy system controls which tools are allowed, with optional human-in-the-loop approval.

Tool Types

TypeDescriptionBest For
Built-inBundled with DuragentCore operations (e.g., bash)
CLICustom scripts with optional READMESimple extensions, any language
MCPModel Context Protocol serversComplex integrations (planned)

Configuration

# agent.yaml
spec:
  tools:
    # Built-in tool
    - type: builtin
      name: bash

    # CLI tool
    - type: cli
      name: code-search
      command: ./tools/code-search.sh
      description: Search codebase for patterns
      readme: ./tools/code-search/README.md

Built-in Tools

NameDescription
bashExecute shell commands in sandbox
web_searchSearch the web (requires BRAVE_API_KEY)
web_fetchFetch a URL and convert to Markdown
schedule_taskCreate a scheduled task
list_schedulesList active schedules
cancel_scheduleCancel a schedule by ID

Memory tools (recall, remember, reflect, update_world) are automatically registered when memory is configured. See Memory.

Searches the web using the Brave Search API.

  • Parameters: query (string, required), count (integer, 1–20, default 5)
  • Requires: BRAVE_API_KEY environment variable. If not set, the tool is silently skipped when registering.
  • Timeout: 30 seconds
spec:
  tools:
    - type: builtin
      name: web_search

web_fetch

Fetches a web page and converts HTML to Markdown.

  • Parameters: url (string, required — http and https only)
  • Download limit: 1 MB response body
  • Output limit: 50 KB sent to the LLM (truncated with notice if larger)
  • Timeout: 30 seconds
  • No API key required — always available as a built-in tool
spec:
  tools:
    - type: builtin
      name: web_fetch

CLI Tools

CLI tools are scripts or binaries that the agent can call. They’re more token-efficient than MCP because the agent reads the README only when it needs the tool (no upfront schema exchange).

FieldRequiredDescription
typeYescli
nameYesTool identifier
commandYesScript path (relative to agent directory)
descriptionNoShort description shown to LLM
readmeNoPath to README (loaded on demand)

Tool Policy

The policy system controls which tools agents can execute. It supports three modes with a deny list safety net.

File Layout

agents/my-agent/
  agent.yaml
  policy.yaml           # Base policy (version controlled)
  policy.local.yaml     # User overrides (gitignored, auto-created)

Policy Modes

ModeDeny ListAllow ListUnknown Commands
dangerousBlocks (always)IgnoredAllowed
askBlocks (always)Auto-approvedRequires human approval
restrictBlocks (always)AllowedDenied

The deny list is always checked first regardless of mode — it acts as an air-gap safety mechanism.

Example Policy

# policy.yaml
apiVersion: duragent/v1alpha1
kind: Policy

mode: ask

deny:
  - "bash:rm -rf /*"
  - "bash:*sudo*"
  - "*:*password*"

allow:
  - "bash:cargo *"
  - "bash:git *"
  - "mcp:github:*"

notify:
  enabled: true
  patterns:
    - "bash:git push*"
  deliveries:
    - type: log
    - type: webhook
      url: https://hooks.slack.com/services/...

Pattern Format

Patterns use tool_type:pattern with glob-style matching:

PatternMatches
bash:cargo *Bash commands starting with “cargo”
mcp:github:*Any tool from github MCP server
*:*secret*“secret” in any tool type

Approval Flow (Ask Mode)

When a command isn’t in the allow or deny list:

  1. Agent requests tool invocation
  2. User sees an approval prompt
  3. User chooses: Allow Once, Allow Always, or Deny
  4. “Allow Always” saves the pattern to policy.local.yaml for future auto-approval

Merge Behavior

When both policy.yaml and policy.local.yaml exist:

FieldStrategy
modeLocal overrides base (unless dangerous)
denyLists merged (union)
allowLists merged (union)
notifyLists merged

Default Behavior

When no policy files exist, the default is dangerous mode with no filtering — matching pre-policy behavior.

Notifications

You can configure notifications for specific tool patterns:

notify:
  enabled: true
  patterns:
    - "bash:rm *"
    - "bash:git push*"
  deliveries:
    - type: log
    - type: webhook
      url: https://hooks.slack.com/services/...

Notifications don’t block execution — they fire after the command runs.