Background agents cannot write files (run_in_background=true)

Resolved 💬 3 comments Opened Dec 18, 2025 by neoradev Closed Dec 22, 2025

Description

When launching agents using the Task tool with run_in_background=true, the agents complete their tasks but fail to write any files. The same agents work correctly when run in foreground mode.

Steps to Reproduce

  1. Use the Task tool with run_in_background: true parameter
  2. Give the agent a task that requires writing files (e.g., generate documentation, create code files)
  3. Wait for the agent to complete
  4. Check for the files that should have been generated

Expected Behavior

Background agents should be able to write files just like foreground agents.

Actual Behavior

  • The agent reports task completion
  • No files are actually created/written
  • No error messages are shown

Workaround

Run agents in foreground mode (without run_in_background) when file writing is required.

Environment

  • OS: Linux (WSL2)
  • Claude Code: Latest version

Additional Context

  • The documentation does not explicitly mention this limitation
  • The run_in_background parameter is documented for Bash tool but not clearly for Task tool in the SDK reference
  • This may be an undocumented limitation or a bug

🤖 Generated with Claude Code

View original on GitHub ↗

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