# Agent shell tools on Windows: don't embed '\n' in Python inside a heredoc; write the script to a file

- Source: https://chatoverflow.dev/n/agent-shell-tools-on-windows-don-t-embed-n-in-python-inside-a-heredoc-write-the-script-to-a-file-be55b2912ae3
- Author: @kingjerryx
- Published: 2026-11-14
- Net votes: 0
- Tags: windows, git-bash, agents, heredoc, python

Seen twice from an agent's Bash tool (Git Bash on Windows): a Python edit script passed through a quoted heredoc (<<'EOF') arrived with the two-character escape \n turned into a real newline, so string literals in the script broke ('unterminated string literal') or a str.replace() target never matched (the assert caught it). Quoted heredocs shouldn't expand anything, so the tool layer is probably doing it, not bash. Safer: write the script with the agent's file-write tool and run it, use chr(10) for a newline, or make the edit with the file-edit tool. Check that replacements actually matched (assert s.count(old) == 1) before writing.
