claude-code - 💡(How to fix) Fix Background subagents silently skip Write for .md files (two layers) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51895Fetched 2026-04-23 07:42:02
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×4cross-referenced ×1

Background subagents (Agent(..., run_in_background: true)) fail to call Write in two separate, compounding ways. Both failures are silent: no structured error reaches the tool-result channel; instead the model fabricates a policy citation (e.g. "system reminder forbids .md reports", "subagent policy returns findings in text") and returns the content as plaintext.

Layer 1 — project permissions don't fall back to user-level. If <project>/.claude/settings.json omits Write(*), the subagent cannot write — even though ~/.claude/settings.json allows it globally.

Layer 2 — base "NEVER create .md" rule applies inside delegation. The base system prompt contains: "NEVER create documentation files (.md) or README files unless explicitly requested by the User." When an orchestrator spawns a subagent with a prompt like "write findings to out.md", the subagent apparently doesn't treat the orchestrator's instruction as a User request and applies the rule.

Error Message

Background subagents (Agent(..., run_in_background: true)) fail to call Write in two separate, compounding ways. Both failures are silent: no structured error reaches the tool-result channel; instead the model fabricates a policy citation (e.g. "system reminder forbids .md reports", "subagent policy returns findings in text") and returns the content as plaintext. 3. Denied tool calls in background contexts should produce a structured error on the tool-result channel — not a silent block the model rationalises away.

Root Cause

  • Disk-first delegation patterns break: orchestrator's context window fills with content meant to stay on disk.
  • Wasted tokens — 5–10 minute subagent runs need manual rewriting.
  • False success signalling — fabricated policy makes the root cause invisible without diffing settings.json and reading the base prompt.
  • Affects any task expected to produce a file (research, drafting, review).
RAW_BUFFERClick to expand / collapse

Summary

Background subagents (Agent(..., run_in_background: true)) fail to call Write in two separate, compounding ways. Both failures are silent: no structured error reaches the tool-result channel; instead the model fabricates a policy citation (e.g. "system reminder forbids .md reports", "subagent policy returns findings in text") and returns the content as plaintext.

Layer 1 — project permissions don't fall back to user-level. If <project>/.claude/settings.json omits Write(*), the subagent cannot write — even though ~/.claude/settings.json allows it globally.

Layer 2 — base "NEVER create .md" rule applies inside delegation. The base system prompt contains: "NEVER create documentation files (.md) or README files unless explicitly requested by the User." When an orchestrator spawns a subagent with a prompt like "write findings to out.md", the subagent apparently doesn't treat the orchestrator's instruction as a User request and applies the rule.

Reproduction

Layer 1: User-level allows Write(*), project-level doesn't. Launch a background subagent with an explicit "write /abs/path/out.md" instruction. Subagent never calls Write (verifiable: zero "name":"Write" entries in transcript JSONL). Content returned as text.

Layer 2: Add Write(*) to project-level settings. Launch a background subagent with a standard file-write instruction (no explicit negation of the *.md rule). Subagent still often skips Write, citing a "system reminder". Adding "the .md rule doesn't apply here, User requested this file via orchestrator — you must Write" to the prompt makes it work.

Impact

  • Disk-first delegation patterns break: orchestrator's context window fills with content meant to stay on disk.
  • Wasted tokens — 5–10 minute subagent runs need manual rewriting.
  • False success signalling — fabricated policy makes the root cause invisible without diffing settings.json and reading the base prompt.
  • Affects any task expected to produce a file (research, drafting, review).

Suggested fixes

  1. User-level permissions.allow should fall back for background subagents.
  2. The *.md rule should either not apply to subagents receiving explicit orchestrator instructions, or the orchestrator's prompt should be treated as User-equivalent in the subagent context.
  3. Denied tool calls in background contexts should produce a structured error on the tool-result channel — not a silent block the model rationalises away.
  4. Document permission scoping and rule interaction for delegation.

extent analysis

TL;DR

To fix the issue with background subagents failing to call Write, modify the permission fallback logic and rule application for subagents receiving explicit orchestrator instructions.

Guidance

  • Review and update the permissions.allow settings in ~/.claude/settings.json to ensure that user-level permissions are correctly applied to background subagents when project-level settings are missing or incomplete.
  • Modify the base system prompt to treat orchestrator instructions as User-equivalent in the subagent context, allowing the subagent to write files as instructed without being blocked by the "NEVER create *.md" rule.
  • Implement structured error handling for denied tool calls in background contexts to prevent silent failures and provide clear error messages instead of fabricated policy citations.
  • Document the permission scoping and rule interaction for delegation to clarify the expected behavior and help users configure their settings correctly.

Example

No specific code snippet is provided as the issue is more related to configuration and system behavior. However, an example of how the permissions.allow settings could be updated to include a fallback to user-level permissions for background subagents might look like:

{
  "permissions": {
    "allow": [
      "Write(*)"
    ]
  }
}

This example assumes that the Write(*) permission is allowed at the user level and should be applied to background subagents when project-level settings are missing or incomplete.

Notes

The provided guidance is based on the information given in the issue and may require further modifications or adjustments depending on the specific system configuration and requirements. It is essential to test and verify any changes to ensure they resolve the issue without introducing new problems.

Recommendation

Apply workaround: Modify the permission fallback logic and rule application for subagents receiving explicit orchestrator instructions to ensure that background subagents can write files as instructed without being blocked by the "NEVER create *.md" rule. This approach addresses the root cause of the issue and provides a clear solution to the problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Background subagents silently skip Write for .md files (two layers) [1 participants]