How to stop an agent doing something, and what each harness gives you to control it. Permission rules decide what the agent may do; a sandbox limits what a command can reach even when it is allowed.
Block a command, for example git push
| OpenCode | |
|---|---|
| How | A deny rule in the permission settings |
| File | opencode.jsonc |
| Example | |
| How it matches | shell resources ending in space-star also match the command without arguments |
| What wins | last configured match wins; configured deny is evaluated before saved approvals and hooks |
| Watch out for | Shell directory inference is best effort and shell runs with host authority. A later configured broad allow can override an earlier configured deny; saved approvals cannot. |
What you can control
| OpenCode | |
|---|---|
| Decisions | allow, ask, deny |
| Permission rules | Built in Cover: tool, command, path, external directory, skill, subagent, MCP Match by: whole-value wildcards over action and resource Conflicts: last configured match wins; agent rules append after global rules; configured deny survives saved approvals and permission hooks Docs |
| Sandbox | Not established external_directory is permission policy, not proof of OS containment. |
| Approval prompts | Built in Remember an approval: once, project Allow always stores durable project-scoped proposed patterns; reject declines all pending requests in the session. 2.1 adds client.permission.saved.update({ id, action?, resource? }) / PATCH /api/permission/saved/:id for changing a saved grant’s tool action or resource pattern. action names the permission subject, not allow/ask/deny; this does not add an editable decision effect. Duplicate project/action/resource combinations return conflict. 2.2.2 schedule `if`/`until` checks run a shell command in the session's directory, with no model call, before a schedule wakes the session. At fire time the check runs unattended: only the shell commands and external directories scanned from its own text are allowed, session permission rules still apply, and it is cut off after 30 seconds. Three failed checks in a row pause the schedule. 2.2.1+ image generation asks permission under the tool's own name (`experimental_image_generate` from 2.2.2; `image_generate` in 2.2.1) with the chosen model as the resource. Saving to a requested path also needs `edit`; image URLs need `webfetch`. From 2.2.2, deny the permission to turn the tool off. In 2.4.0 the tool is generate_image. Configured permission rules using the old name migrate automatically. Saved always-allow approvals require fresh approval. Docs |
| Skills granting tools | Not supported The skill permission controls loading; skill frontmatter does not grant tool access. Docs |
| Hooks that decide | Built in
Can: allow, ask, deny The hook runs after configured-deny evaluation, so it cannot override a configured deny. Since 2.0.30, MCP tool calls include their input in permission-evaluation metadata.input; absent input becomes {}. This does not change configured-deny precedence. Docs |
| Where rules live |
|
Sources
OpenCode
- OpenCode 2.0.29 permission evaluation and saved approval boundary, Source code, checked 2026-10-15
- OpenCode 2.0.29 configured denies precede saved grants and permission hooks, Source code, checked 2026-10-15
- Released OpenCode 2.0.29 permission documentation, Documentation, checked 2026-10-15
- OpenCode 2.0.29 skill parser, Source code, checked 2026-10-15
- OpenCode 2.0.30 MCP tool input passed to permission evaluation, Source code, checked 2026-10-16
- OpenCode v2.1.1: packages/protocol/src/groups/permission.ts, Source code, checked 2026-10-21
- OpenCode 2.2.2: packages/core/src/schedule/check.ts, Source code, checked 2026-10-30
- OpenCode 2.2.2: packages/schema/src/schedule.ts, Source code, checked 2026-10-30
- OpenCode 2.2.2: packages/core/src/schedule.ts, Source code, checked 2026-10-30
- OpenCode 2.2.2: packages/core/src/tool/plugin/image-generate.ts, Source code, checked 2026-10-30
- OpenCode 2.2.2: packages/core/src/tool/plugin/image-generate.ts, Source code, checked 2026-10-30
- OpenCode 2.4.0 release notes, Documentation, checked 2026-11-24