Skip to content

fix(bash): preserve UTF-8 across output chunk boundaries - #5067

Merged
yonib05 merged 1 commit into
strands-agents:mainfrom
ikenyal:agent-tasks/4461
Nov 18, 2026
Merged

yonib05 merged 1 commit into
strands-agents:mainfrom
ikenyal:agent-tasks/4461

Conversation

@ikenyal

@ikenyal ikenyal commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Human Overview

I wanted the TypeScript bash tool to preserve non-ASCII UTF-8 text, including Japanese and emoji, when command output arrives in separate chunks. This change keeps decoding state for each output stream without changing how commands or sessions are managed.

Description

Non-ASCII bash output can be silently corrupted when a UTF-8 character crosses stdout or stderr chunk boundaries. Decoding is scoped to each stream and command so incomplete trailing bytes cannot affect a later command.

Related Issues

Related to #4461: addresses the TypeScript bash-tool path in Additional Context only. The Python sandbox fixes are separate; this PR does not close the issue.

Documentation PR

No site documentation changes or new examples are needed for this internal decoding fix.

Type of Change

Bug fix

Testing

Ran TypeScript build, lint, formatting/type checks, browser-bundle check, and Node unit tests with coverage (5,026 passed). A real bash invocation check covered split stdout/stderr, incomplete and invalid UTF-8, persistent variables, restart, and timeout recovery. No AWS or model calls. Provider-backed integration tests, browser tests, package smoke tests, and OS/version matrices were not run. Existing dependency audit findings are disclosed below.

  • I ran hatch run prepare (not applicable: TypeScript-only change; npm checks above were run)

Additional Details

Existing dependency advisories and validation scope

The repository's pre-push script passed the TypeScript code checks and Node coverage suite. Its only remaining failed step was npm audit --audit-level=high: 5 existing dependency advisories (2 moderate, 3 high), also reported by installation from the unchanged main lockfile. The high-severity entries are @modelcontextprotocol/client, @modelcontextprotocol/sdk, and nanoid. No dependency or lockfile changes are included.

The regression test fails on the unchanged decoding implementation with replacement characters in place of the original text. The real bash check passed nine assertions without invoking a model. The complexity report was size/xs and complexity/low (no increase in touched functions).

Prepared with coding-agent assistance; the contributor approved the Human Overview and submission.

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly (not applicable: internal decoding fix)
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed — no new docs needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published (not applicable: no dependent PRs)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions github-actions Bot added typescript Pull requests that update typescript code bug Something isn't working area-tool Tool behavior/api labels Oct 11, 2026
@ikenyal
ikenyal marked this pull request as ready for review October 11, 2026 23:04
@ikenyal
ikenyal requested a review from a team as a code owner October 11, 2026 23:04
@ikenyal
ikenyal requested a review from Unshure October 11, 2026 23:04
@github-actions github-actions Bot added complexity/low Touched functions have low cognitive complexity (<=10) size/xs labels Nov 10, 2026
@yonib05
yonib05 merged commit 7fe5bc1 into strands-agents:main Nov 18, 2026
55 of 57 checks passed
arronbailiss added a commit to arronbailiss/harness-sdk that referenced this pull request Nov 21, 2026
…ds-agents#5067)

The bash tool collects each command's output bytes and decodes them once, so a character split
between pipe chunks is already kept whole and decoding state never leaks into the next command.
The ported case pins that on stdout and stderr.
arronbailiss added a commit to arronbailiss/harness-sdk that referenced this pull request Nov 23, 2026
…ds-agents#5067)

The bash tool collects each command's output bytes and decodes them once, so a character split
between pipe chunks is already kept whole and decoding state never leaks into the next command.
The ported case pins that on stdout and stderr.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-tool Tool behavior/api bug Something isn't working complexity/low Touched functions have low cognitive complexity (<=10) size/xs typescript Pull requests that update typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants