.NET: [Bug]: FileSystemAgentFileStore.WriteAsync writes a UTF-8 byte order mark at the start of every file

Open
#8,566 1 comment 0 reactions 1 assignee View on GitHub

@rogerbarreto is already working on this.

Since Sep 20, 2026.

Assessment

This issue has not been assessed yet.

Description

.NET agents reproduced
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/agent-framework

All issues in microsoft/agent-framework

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.