[dotnet-port-fixes] Preserve shelltool UTF-8 head/tail ordering#537
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the internal tool/shelltool bounded output accumulator (headTailBuffer) to preserve correct UTF-8 ordering between head and tail segments, aligning behavior with the referenced upstream .NET fix while keeping the Go public API unchanged.
Changes:
- Seal the head once a full UTF-8 rune no longer fits, ensuring subsequent runes are captured in the tail to preserve output order.
- Adjust tail eviction logic to avoid premature truncation when the total captured output is still within the configured cap.
- Add focused internal tests covering exact-cap and overflow UTF-8 scenarios (including truncation marker expectations).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tool/shelltool/localshell.go | Updates headTailBuffer write/eviction behavior to preserve UTF-8 ordering across head/tail. |
| tool/shelltool/localshell_internal_test.go | Adds parity-style tests to validate UTF-8 ordering and truncation marker behavior at/over cap. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Cross-Repo Parity Review — PR #537Scope determination: In scope (internal behavior change in a public package). Changed Go contract: No exported identifiers were added, removed, or modified. The only changes are to the private Upstream parity check: The PR description cites the upstream .NET commit Verdict: ✅ This PR restores cross-repo parity with the .NET implementation. No divergences introduced, no public Go API changes, no sample or example changes required. No parity issues found.
|
Summary
Aligned Go's internal
tool/shelltoolhead/tail output buffer with the upstream .NET UTF-8 ordering fix from commit85c00fc55b6f8cef8b88e83f364b527a0d5cd275.The Go
headTailBuffernow seals the head once a full rune no longer fits, keeps all later runes in the tail, and only evicts tail runes after the total captured output exceeds the configured cap. This preserves output order for mixed ASCII and multibyte UTF-8 content while keeping the existing public Go API unchanged.Ported .NET PRs
HeadTailBufferUTF-8 orderBreaking Changes
No.
Tests and Examples
go test ./tool/shelltoolNotes
85c00fc55b6f8cef8b88e83f364b527a0d5cd275(https://github.com/microsoft/agent-framework/commit/85c00fc55b6f8cef8b88e83f364b527a0d5cd275)Closes #521