Description
HeadTailBuffer may reorder UTF-8 characters and silently discard output when a multi-byte rune does not fit in the remaining head capacity.
The returned result can report Truncated == false even though data was removed.
This affects command output containing non-ASCII characters near the head/tail boundary.
Code Sample
HeadTailBuffer buffer = new(20);
buffer.AppendLine("aaaaaaa\U0001F600\U0001F600\U0001F600");
var (text, truncated) = buffer.ToFinalString();
The input, including the appended newline, is exactly 20 UTF-8 bytes:
aaaaaaa: 7 bytes
Three emoji runes: 12 bytes
Newline: 1 byte
Expect:
text == "aaaaaaa😀😀😀\n"
truncated == false
Actual:
text == "aaaaaaa\n😀😀"
truncated == false
The first emoji is silently discarded, and the newline is moved before the remaining emoji runes.
Package Versions
Microsoft.Agents.AI.Tools.Shell 1.12.0-preview.260629.1
.NET Version
.NET 10
Description
HeadTailBuffermay reorder UTF-8 characters and silently discard output when a multi-byte rune does not fit in the remaining head capacity.The returned result can report
Truncated == falseeven though data was removed.This affects command output containing non-ASCII characters near the head/tail boundary.
Code Sample
The input, including the appended newline, is exactly 20 UTF-8 bytes:
aaaaaaa: 7 bytes
Three emoji runes: 12 bytes
Newline: 1 byte
Expect:
text == "aaaaaaa😀😀😀\n"
truncated == false
Actual:
text == "aaaaaaa\n😀😀"
truncated == false
The first emoji is silently discarded, and the newline is moved before the remaining emoji runes.
Package Versions
Microsoft.Agents.AI.Tools.Shell 1.12.0-preview.260629.1
.NET Version
.NET 10