You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] AI ignores AGENTS.md bat-file rules on Windows (CRLF + encoding) despite existing guardrails #31275
Despite AGENTS.md containing explicit Windows bat-file rules (UTF-8 without BOM, CRLF line endings, chcp 65001 as second line, no BOM before @echo off), the AI agent violates these rules in practice. On the same system that hosts the AGENTS.md file, the AI has:
Written .bat files with LF-only line endings (causes instant crash on cmd.exe)
Written .bat files with GBK encoding instead of UTF-8 (because the system code page is 936 and the AI incorrectly chose GBK over the AGENTS.md rule)
Failed to add chcp 65001 as the second line
Root Cause (Three Layers)
Layer 1 — AI Model Behavior
The AI model generates LF (\n) line endings natively. There is no post-processing step in the write tool that detects .bat/.cmd files on Windows and converts endings to CRLF.
Layer 2 — bash Tool Serialization
When the AI passes content through the bash tool (PowerShell command string via JSON), any CRLF in the content is stripped to LF. Even if the AI intended CRLF, the transport layer loses it. See also issue #31224.
Layer 3 — No AGENTS.md Enforcement at Write Time
The write tool at packages/opencode/src/tool/write.ts has no mechanism to check AGENTS.md rules before writing. The AI must consciously remember to apply the rules, which is unreliable.
The scope here (AGENTS.md enforcement at the tool layer) extends slightly beyond #31224, but the root cause and proposed fix largely overlap. You may want to consider whether this should be consolidated with #31224 or kept separate to track the AGENTS.md-awareness angle specifically.
Activity
github-actions commentedon Jun 7, 2026
This issue might be a duplicate of existing issues. Please check:
The scope here (AGENTS.md enforcement at the tool layer) extends slightly beyond #31224, but the root cause and proposed fix largely overlap. You may want to consider whether this should be consolidated with #31224 or kept separate to track the AGENTS.md-awareness angle specifically.