Skip to content

feat: make Shell input and output limits configurable - #401

Merged
pgrayy merged 4 commits into
mainfrom
feature/pgrayy/configurable-shell-sizes
Nov 11, 2026
Merged

pgrayy merged 4 commits into
mainfrom
feature/pgrayy/configurable-shell-sizes

Conversation

@pgrayy

@pgrayy pgrayy commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Description

Box currently uses fixed Shell input and output limits. This change lets applications configure each limit independently to match their workload and resource requirements.

Expose optional byte counts as limits.shell.max_input and limits.shell.max_output. Positive values bound bytes; 0 disables the corresponding Shell limit. Omission retains the defaults of 256 KiB input and 64 KiB output.

The stored settings reach every hosted Shell call. Explicit sizes use record version 31; configurations that omit them keep their existing version. Older Core builds reject the new keys and record version. Shell still uses max_output to bound source-file reads. Its separate transport budgets remain in force, including when a Shell limit is disabled. The docs explain the memory implication of larger or unlimited settings.

Related PR #403 fixes an existing Shell bug that bypasses the input limit for submissions containing a newline. It is independent of this configuration change; neither PR requires the other to merge first. The configuration reference documents that limitation.

Type of Change

New feature

Testing

  • Core tests with all features: 1,464 passed, 0 failed, 6 existing ignored tests, including the configuration and runtime regressions.
  • All-feature and no-default-features builds, formatting, Clippy, and all 27 site-manifest tests passed with no new warnings.
  • Mutation checks confirmed that the configuration tests detect an ignored input setting and a limit reset after the first call. The combined backend/Shell-size test also fails when backend version 30 incorrectly takes precedence over version 31. The tests pass with the implementation restored.
  • The complete deterministic gate passed: 129 cases passed, 12 declared Linux-only skips, full coverage, and a passing harness unit stage.
  • The examples gate passed with no scripted examples available. Two existing runtime checks skipped on this host: the Homebrew python3 path is absent, and the filesystem refuses non-UTF-8 pathnames.
  • Local validation was on macOS; the updated commit also runs the Linux and macOS CI checks.

Checklist

  • I have read the contributing guide.
  • I have reviewed the implementation.
  • The change covers Shell size configuration, tests, and documentation.
  • Regression tests cover omitted and zero limits, independent limits, persistence, repeated calls, output capture, and source loading.
  • Documentation describes the settings and compatibility consequences.

## Problem

Fixed Shell input and output ceilings prevent operators from sizing larger command text, captures, and sourced scripts for their workloads.

## Solution

Add optional positive byte counts at limits.shell.max_input and limits.shell.max_output. Preserve the 256 KiB input and 64 KiB output defaults and existing timeout behavior. Persist explicit sizes under record version 30 and retain existing versions when sizes are omitted. Apply the settings whenever the broker constructs Shell, including later calls. Document current source-loading semantics and separate transport limits.

## Tests

Full Core package tests passed with all features, including site_manifest. The shell_size_limits tests cover validation and serialization; explicit_shell_sizes_require_their_record_version and shell_sizes_beside_an_agent_ingress_store_the_shell_size_version cover persistence compatibility. raised_input_limits_survive_repeated_calls_on_one_program and both configured_shell_* integration tests cover runtime enforcement. Independent mutation checks made each new regression test fail.

All-feature build, no-default-features build, formatting, and workspace Clippy passed. The deterministic runner recorded 129 passing cases and 12 declared Linux-only skips; two unchanged host TCP timing assertions failed in its original unit stage. The full 103-test harness unit target passed on retry without code changes. The full deterministic script was not repeated. The examples gate found no scripted examples. Linux was not built locally.
Comment thread crates/box/src/run/broker/shell.rs Resolved
Comment thread crates/box/src/record/config/limits.rs Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Approve

I re-reviewed f92c835 against a848cbc. The newline bypass is fixed in vendored exec::execute, and the fix is recorded in UPSTREAM.md. The new 0 = unlimited behavior is consistent everywhere Shell reads these limits. I found no new issues.

Checked and held
  • New input check: every caller of exec::execute now gets the check before choosing single-line or multi-line evaluation. That covers Shell::run, Shell::execute, eval, find -exec, xargs, and Lua popen/os.execute. The EXIT trap still runs after a refusal, the same as the old single-line refusal.
  • max_input = 0: all three checks (execute, execute_admitted_line, capture_output) treat 0 as unlimited.
  • max_output = 0: every read site is unlimited at 0: read_to_end_limited/read_to_string_limited, append_limited, read_receivers_limited, the $(...) truncation, and HttpRequest.max_response in both the vendored and Box kernels.
  • Record version: an explicit 0 still selects record version 30, and the round-trip and max_input()/max_output() tests now cover it.
  • Tests: the Shell, broker, and real-box tests each send single-line, trailing-newline, and multi-line input. builder_max_input passes locally.
  • Docs: config.md, shell.md, docs/design/shell.md, and crates/box/README.md all describe 0 and the trusted-process memory tradeoff the same way.

Thanks for adding a regression test that fails without the fix.

@pgrayy pgrayy changed the title Make Shell input and output limits configurable feat: make Shell input and output limits configurable Nov 11, 2026
@strands-agents strands-agents deleted a comment from github-actions Bot Nov 11, 2026
Keep this PR focused on Shell limit configuration. PR #403 owns the vendored
Shell guard and its newline regression test. Restore the configuration tests'
single-line repeated calls while retaining finite and unlimited values.
Remove the multiline-enforcement claim from the configuration design page.
Comment thread crates/box/tests/box_shell.rs Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Approve

I re-reviewed 8166ff0 against e56e589. The new commit is a merge of main (#311 backends, #296 Shell cwd). The PR's own changes now consist of the record version moving to 31 and a sentence in config.md about the newline limitation. That sentence resolves my earlier merge-order concern. I found no new issues.

Checked and held
  • Version order: record_version checks has_size_limits() (31) before has_backend (30). A record with both is stamped 31 and keeps both. shell_sizes_beside_a_backend_store_the_shell_size_version and …_beside_an_agent_ingress_… cover this.
  • Parse: 31 is in the accepted list. Because the stored version must equal the required version, a record with size limits stamped 21–30 is refused, and so is a 31 record without them.
  • Merge resolution: the configured max_input/max_output replace main's SHELL_MAX_INPUT/MAX_CAPTURE_STREAM_BYTES. Main's command_timeout/request_timeout and host_spawner (ToolSpawner) are kept in ShellSpec and host().
  • Docs: native-filesystem-policy.md lists 30 (backend) and 31 (sizes), and crates/box/AGENTS.md names SHELL_SIZE_LIMITS_RECORD_VERSION as the newest frozen record version.
  • Tests: record::config, shell_limits_round_trip_in_the_required_record_version, and raised_input_limits_survive_repeated_calls_on_one_program pass locally (230 passed, 0 failed).

@pgrayy
pgrayy enabled auto-merge (squash) November 11, 2026 21:05
@pgrayy
pgrayy merged commit 9922369 into main Nov 11, 2026
31 of 32 checks passed
@pgrayy
pgrayy deleted the feature/pgrayy/configurable-shell-sizes branch November 11, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Shell/Monty enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants