OpenWriterControle/.opencode/context/openagents-repo/errors/tool-permission-errors.md
Darren Hinde 9c7f1c3099
Fix/164 permission key compatibility (#171)
* fix: migrate all agents to OpenCode v1.1.1+ permission (singular) key

Resolves #164

## Changes

### Agent Files (16 files)
- Migrated all agent frontmatter from deprecated `permissions:` (plural) to `permission:` (singular)
- Updated: core agents (OpenCoder, OpenAgent, RepoManager)
- Updated: code subagents (TestEngineer, CoderAgent, BuildAgent, CodeReviewer)
- Updated: core subagents (TaskManager, DocWriter, ExternalScout, ContextScout, ContextManager, Context Retriever)
- Updated: development subagents (DevOpsSpecialist, FrontendSpecialist)
- Updated: system-builder subagents (ContextOrganizer, WorkflowDesigner)

### Context Documentation (3 files)

#### Updated: agent-frontmatter.md
- Fixed field name from `permissions:` to `permission:`
- Updated all examples to use correct singular form
- Corrected "Wrong Field Names" section to show `permissions:` as deprecated
- Updated validation checklist and valid keys list

#### Updated: agent-metadata.md
- Added clarification that `permission` replaces deprecated `permissions`
- Added comprehensive migration guide with before/after examples
- Added validation steps for migration

#### New: permission-patterns.md
- Comprehensive 400+ line permission patterns reference
- Permission evaluation order (last-matching-wins)
- Complete table of valid permission keys
- Agent type patterns (read-only, write-enabled, orchestrators)
- Security patterns (sensitive files, dangerous commands)
- Task permission patterns
- Complete working examples for each agent type
- Validation checklist

## Verification

- ✅ 0 agents using deprecated `permissions:` (plural)
- ✅ 16 agents using correct `permission:` (singular)
- ✅ All permission patterns follow last-matching-wins order
- ✅ Security denials applied consistently
- ✅ Context documentation updated and accurate

## Migration Details

Based on official OpenCode documentation (https://opencode.ai/docs/agents/):
- OpenCode v1.1.1+ uses `permission:` (singular)
- Deprecated: `permissions:` (plural)
- Granular control with last-matching-wins evaluation
- Valid actions: "allow", "ask", "deny"

All agents now comply with OpenCode v1.1.1+ standards.

* fix: correct YAML errors and restore missing permissions in agent configs

- Fix repo-manager.md duplicate permission section
- Fix externalscout.md YAML indentation error
- Remove old tools: section from devops-specialist.md
- Restore context file permissions in context-manager.md
- Restore test command permissions in tester.md
- Clean up formatting in coder-agent.md

All 20 agent files now have valid YAML frontmatter with proper permission blocks.

* fix: standardize permission key across agent files

- Updated all instances of `permissions:` to `permission:` in agent frontmatter for consistency.
- Removed deprecated `write:` and `edit:` sections from externalscout.md.
- Adjusted related documentation to reflect the singular form of permission key.

These changes ensure compliance with OpenCode v1.1.1+ standards and improve YAML structure across the repository.
2026-02-03 22:09:09 +00:00

4.5 KiB

Tool Permission Errors

Purpose: Diagnose and fix tool permission issues in agents

Last Updated: 2026-01-07


Error: Tool Permission Denied

Symptom

{
  "type": "missing-approval",
  "severity": "error",
  "message": "Execution tool 'bash' called without requesting approval"
}

Or agent tries to use a tool but gets blocked silently (0 tool calls).


Cause

Agent has tool disabled or denied in frontmatter:

# In agent frontmatter
tools:
  bash: false    # ← Tool disabled

permission:
  bash:
    "*": "deny"  # ← Explicitly denied

How it works:

  • bash: false means agent doesn't have access to bash tool
  • Framework enforces this - agent can't use bash even if prompt says to
  • NOT an approval issue - it's a permission restriction

Solution

Option 1: Emphasize Tool Restrictions in Prompt (Recommended)

Add critical rules section at top of agent prompt:

<critical_rules priority="absolute" enforcement="strict">
  <rule id="tool_usage">
    ONLY use: glob, read, grep, list
    NEVER use: bash, write, edit, task
    You're read-only—no modifications allowed
  </rule>
  <rule id="always_use_tools">
    ALWAYS use tools to discover files
    NEVER assume or fabricate file paths
  </rule>
</critical_rules>

Why this works: Makes tool restrictions crystal clear in first 15% of prompt.

Option 2: Enable Tool (If agent needs it)

tools:
  bash: true  # ← Enable if agent legitimately needs bash

Warning: Only enable if agent truly needs the tool. Read-only subagents should NOT have bash/write/edit.


Prevention

For Read-Only Subagents:

# Correct configuration for read-only subagents
tools:
  read: true
  grep: true
  glob: true
  list: true
  bash: false    # ← No execution
  edit: false    # ← No modifications
  write: false   # ← No file creation
  task: false    # ← No delegation (subagents don't delegate)

permissions:
  bash:
    "*": "deny"
  edit:
    "**/*": "deny"
  write:
    "**/*": "deny"

For Primary Agents:

# Primary agents may need execution tools
tools:
  read: true
  grep: true
  glob: true
  list: true
  bash: true     # ← May need for operations
  edit: true     # ← May need for modifications
  write: true    # ← May need for file creation
  task: true     # ← May delegate to subagents

Error: Subagent Approval Gate Violation

Symptom

{
  "type": "missing-approval",
  "message": "Execution tool 'bash' called without requesting approval"
}

In a subagent test.


Cause

Subagents should NOT have approval gates - they're delegated to by primary agents who already got approval.

The issue is usually:

  1. Subagent trying to use restricted tool (bash/write/edit)
  2. Test expecting approval behavior (wrong for subagents)

Solution

Fix 1: Remove Tool Usage

Subagents shouldn't use execution tools. Update prompt to emphasize read-only nature.

Fix 2: Update Test Configuration

Subagent tests should use auto-approve:

approvalStrategy:
  type: auto-approve  # ← No approval gates for subagents

Fix 3: Check Tool Permissions

Ensure subagent has bash: false in frontmatter.


Error: Tool Not Available

Symptom

Agent tries to use a tool but framework says "tool not available".


Cause

Tool not enabled in frontmatter:

tools:
  glob: false  # ← Tool disabled

Solution

Enable the tool:

tools:
  glob: true  # ← Enable

Verification Checklist

After fixing tool permission:

  • Agent frontmatter has correct tools: configuration?
  • Prompt emphasizes allowed tools in critical rules section?
  • Prompt warns against restricted tools?
  • Test uses auto-approve for subagents?
  • Test verifies tool usage with mustUseTools?

Tool Permission Matrix

Agent Type bash write edit task read grep glob list
Read-only subagent ❌ ❌ ❌ ❌ ✅ ✅ ✅ ✅
Primary agent ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Orchestrator ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅

  • concepts/subagent-testing-modes.md - Understand subagent testing
  • guides/testing-subagents.md - How to test subagents
  • examples/subagent-prompt-structure.md - Prompt structure with tool emphasis

Reference: .opencode/agent/ContextScout.md (lines 14-28, tool configuration)