Skip to content

fix(shell): stream output losslessly with backpressure - #118

Open
furgalep wants to merge 7 commits into
mainfrom
fix/bash-session-streaming
Open

fix(shell): stream output losslessly with backpressure#118
furgalep wants to merge 7 commits into
mainfrom
fix/bash-session-streaming

Conversation

@furgalep

Copy link
Copy Markdown
Collaborator

Summary

  • deliver BashSession streaming output incrementally and without truncation
  • bound in-process memory with one pending read per stdout and stderr stream, allowing consumer backpressure
  • preserve split UTF-8 sequences with incremental decoders
  • propagate early consumer closure through ShellTools, interrupt the active command, and resynchronize the persistent shell
  • use the existing TruncatingStringIO for bounded buffered run output instead of unbounded byte accumulation

Behavioral contract

  • run and run_with_timeout_flag return bounded head/tail output
  • run_stream delivers every decoded chunk exactly once and emits one terminal done event
  • stdout and stderr ordering is preserved independently
  • timeout and natural exit code 124 remain distinguishable
  • abandoning a stream does not leak a running command or stale output into the next command

Tests

  • 58 focused shell tests pass
  • covers large stdout and stderr, incremental delivery, UTF-8 read boundaries, timeout recovery, natural exit 124, cross-loop reuse, and consumer abandonment
  • Ruff check and format validation pass

Configuration note

Buffered BashSession output currently retains the existing fixed 30,000-character budget per stream. Wiring this to the agent TruncationConfig capture settings is intentionally left for a separate configuration change.

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
@furgalep
furgalep force-pushed the fix/bash-session-streaming branch from 4c13978 to 14d4929 Compare August 10, 2026 13:07
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
@furgalep
furgalep force-pushed the fix/bash-session-streaming branch from d6f1f91 to a1adf84 Compare August 12, 2026 07:31
@furgalep furgalep self-assigned this Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant