Skip to content

fix(sandbox): keep numeric command output in the docker terminal - #1463

Open
DZH166 wants to merge 1 commit into
FoundationAgents:mainfrom
DZH166:fix/docker-terminal-numeric-output
Open

DZH166 wants to merge 1 commit into
FoundationAgents:mainfrom
DZH166:fix/docker-terminal-numeric-output

Conversation

@DZH166

@DZH166 DZH166 commented Nov 6, 2026

Copy link
Copy Markdown

Problem

DockerSession.execute() filters command output with:

line.strip() == b"echo $?" or line.strip().isdigit()

The isdigit() branch was meant to drop the single exit-status line printed by echo $?, but it drops every output line that consists only of digits. The exit status is always the last line before the $ prompt, so numeric command output is silently swallowed while the tool reports success:

wc -l data.txt  -> ''            (expected '42')
seq 1 3         -> ''            (expected '1\n2\n3')
echo hi         -> 'a\nb'        (unaffected)

This hits every sandboxed run (config.sandbox.use_sandbox=true -> DockerSandbox.run_command / SandboxFileOperator) whenever a command prints counts, line numbers, hashes-less numeric ids, timestamps or seq output.

Fix

Track the line count and only drop the final status line that precedes the prompt, instead of dropping any numeric line.

Tests

tests/sandbox/test_terminal_output_parsing.py (3 tests):

  • wc -l output is preserved;
  • seq 1 3 output is preserved;
  • ordinary text output is unchanged.
pytest tests/sandbox/test_terminal_output_parsing.py -q    # before: 2 failed, 1 passed   after: 3 passed

The prompt/exit-status filter dropped every output line that consisted only of digits, not just the single 'echo \True' status line, so commands such as wc -l, grep -c or seq returned an empty result while reporting success. Drop only the final status line before the prompt.
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