.NET: [Bug]: FileSystemAgentFileStore.WriteAsync writes a UTF-8 byte order mark at the start of every file
@rogerbarreto is already working on this.
Since Sep 20, 2026.
Assessment
This issue has not been assessed yet.
Description
Describe the bug
Microsoft.Agents.AI.FileSystemAgentFileStore.WriteAsync (Microsoft.Agents.AI 1.21.0) writes files with a UTF-8 BOM (EF BB BF). Every file an agent creates or edits through the file-access tools therefore starts with a BOM, which shows up as a spurious first-byte change in code review, breaks tools that expect BOM-less UTF-8 (shebangs, some YAML/JSON consumers, git diff noise), and differs from what File.WriteAllText produces by default.
To reproduce
var store = new FileSystemAgentFileStore(root);
await store.WriteAsync("a.cs", "namespace A;");
var bytes = File.ReadAllBytes(Path.Combine(root, "a.cs"));
// bytes[0..3] == { 0xEF, 0xBB, 0xBF }
Expected behavior
Write UTF-8 without a BOM (new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)), matching File.WriteAllText and what source files in a repository normally contain. If the file already starts with a BOM, preserving it would be a reasonable option.
Workaround
We wrap the store (it is sealed) and strip the BOM after each write: https://github.com/DataOptik/dataoptik-ai-agent-loop-harness/blob/develop/src/DataOptik.Harness.Agents/Tools/BomFreeFileStore.cs
Environment
- Microsoft.Agents.AI 1.21.0, Microsoft.Agents.AI.Harness 1.21.0-preview.260911.1
- .NET 10, Windows 11
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 2.3k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 362
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/agent-framework
-
python triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/agent-framework#8599 · 1 comment ·
-
python
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
microsoft/agent-framework#8590 ·
-
python triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/agent-framework#8523 · 1 comment ·
-
.NET compaction documentation
Difficulty 1/5 Under an hour Newbie friendliness 82/100
microsoft/agent-framework#4629 · 1 comment ·
-
.NET harness python reproduced
microsoft/agent-framework#8620 · 1 comment · 1 assignee ·
All issues in microsoft/agent-framework
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100