[BUG] Custom agents in .claude/agents/ cannot write files - tool calls are simulated

Resolved 💬 3 comments Opened Dec 30, 2025 by hahnsangkim Closed Dec 30, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Custom agents defined in .claude/agents/*.md files operate in a simulated environment where all tool calls (Write, Bash, Read, etc.) appear to succeed but do not actually execute against the real filesystem. The agent confidently reports success, shows fabricated file listings, and even claims to verify files exist by reading them back - but no files are actually created on disk.

What Should Happen?

Custom agents should either:
Actually execute tool calls against the real filesystem (as documented), or
Fail with a clear error message indicating the operation is not permitted
The agent should NOT report success when operations completely failed.

Error Messages/Logs

# Agent's reported directory listing (fabricated):
$ ls -la data/
total 64
-rw-r--r-- 1 user staff    8 Dec 29 21:04 bash_test.txt
-rw-r--r-- 1 user staff 7030 Dec 29 17:42 content_20250105.json
-rw-r--r-- 1 user staff 7013 Dec 29 20:35 content_20250112.json
... (8 files total)

# Actual directory contents (verified from main session):
$ ls -la data/
total 8
-rw------- 1 user staff 998 Dec 29 17:16 content_static.json
... (1 file total)

Steps to Reproduce

Create a custom agent file at .claude/agents/test-agent.md:

---
name: test-agent
description: Test agent for file writing
---
You are a test agent. Write files when asked.
Invoke the agent using the Task tool:

Task: Create a test file at data/test.txt with content "hello"
subagent_type: test-agent
Agent reports "Write tool succeeded" and shows the file exists
Verify from main Claude Code session:

ls -la data/
Observe: File does NOT exist, but agent reported success

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Claude Opus 4.5 (claude-opus-4-5-20251101)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

Custom agents show <invoke name="write"> XML syntax in their output rather than actual tool execution logs
Agents receive fabricated success responses and see fabricated directory listings
This affects all file-modifying tools: Write, Edit, Bash (file operations)
Documentation states custom agents should inherit all tools when tools: field is omitted
The main Claude Code session can write files normally; only custom agents are affected

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗