allowedWritePaths ignored in Ask mode (only honored in Explore) — forces automations/Tasks into Allow-All

Author: ZerVisionGoCreated Sep 20, 2026Updated Sep 20, 2026

TL;DR: allowedWritePaths is honored in Explore/safe mode but ignored in Ask mode — Ask mode prompts on every write regardless of the allowlist. This forces automations/Tasks (unattended child sessions) into Allow-All, which is strictly less safe. Fix in the linked PR.

Craft Agents Version

0.13.3(main @ e8963854)

Operating System

macOS (Apple Silicon)

OS Version

macOS 26.4

AI Provider

不相关——权限判定逻辑,与 provider 无关

Description

allowedWritePaths(在 permissions.json 里配置的、允许 agent 写入的路径 glob)在 Explore/safe 模式下生效:shouldAllowToolInModepackages/shared/src/agent/mode-manager.ts)对匹配路径的 Write/Edit 直接放行。

Ask 模式忽略它:shouldPromptInAskModepackages/shared/src/agent/core/pre-tool-use.ts)的 file-write 分支只查 session 级的 isCommandWhitelisted不查 allowedWritePaths,所以在 Ask 模式下每次写文件都会弹权限确认,无论路径是否在允许列表里。

Steps to Reproduce

  1. 工作区 permissions.json"allowedWritePaths": ["/abs/path/content/**"]
  2. 会话切到 Ask(询问)模式
  3. 让 agent 写 /abs/path/content/x.md

Expected Behavior

路径在 allowedWritePaths 内 → 不弹窗(与 Explore 模式一致);路径在允许列表外 → 照常弹窗。

Actual Behavior

无论路径是否在 allowedWritePaths 内,Ask 模式都弹权限确认。

Additional Context

实际影响:Automations 和 Tasks 的子会话是无人值守运行的,Ask 模式下每次写文件都卡在没人应答的权限弹窗上,于是只能退回 Allow-All——而 Allow-All 允许 agent 往任何地方写、且完全不问。这比"Ask 模式 + 自动放行配置好的写路径"危险得多:后者能让一个 Task 只往 content/** 写而不弹窗,同时任何越界写入照样弹窗拦下。

修复见 PR:export Explore 模式已经在用的 matchesAllowedWritePath,在 shouldPromptInAskMode 的 file-write 分支里查一遍 allowedWritePaths,命中就不弹窗。允许列表外的写入、以及没配允许列表的工作区,行为不变。

Source: craft-ai-agents/craft-agents-oss