Repository navigation
fix(agent-runtime): bound Bash progress by UTF-16 length without splitting surrogate pairs - #1939
Merged
Merged
Conversation
…tting surrogate pairs The cap was measured in UTF-16 code units, then the slice kept that many code points. Emoji and other supplementary-plane characters are two units each, so truncated Bash progress stayed about twice the cap and every later chunk was cut again from that oversized string. Spend the same head/tail budget in code units and drop a code point that does not fit, so a surrogate pair is never split.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1938
What
appendToolProgressnow spends the head and tail budgets in UTF-16 code units, the same unit as theMAX_TOOL_PROGRESS_CHARScheck. Two small helpers take a prefix and a suffix by code units and leave out a code point that would not fit, so a surrogate pair is never split. The 60/40 head/tail split and the marker are unchanged.Why
The budget was counted in code points while the cap is checked in code units, so supplementary-plane output (emoji etc.) was "truncated" to about twice the cap:
"😀".repeat(40_000)came out at 131,036 code units against a 65,536 cap.How tested
runtime.test.ts, via the existing Bashtools.outputfixture: emoji over the cap stays ≤ 65,536 with no lone surrogates; a cut landing on a surrogate pair keeps it whole; ASCII over the cap is unchanged (exactly the cap, same marker position); under-cap output is appended as-is. The two supplementary-plane cases fail on unmodifiedmain.packages/agent-runtime: full vitest 106 files / 1495 tests pass;tsc --noEmitclean;pnpm lint:biomeandscripts/check-architecture.mjspass.Scope
appendToolProgressinruntime.tsand tests. No constant or caller changes.