Skip to content

fix(local-env): keep timeout output as text and preserve stderr - #252

Open
Ricardo-M-L wants to merge 1 commit into
simular-ai:mainfrom
Ricardo-M-L:fix/local-bash-timeout-text
Open

Ricardo-M-L wants to merge 1 commit into
simular-ai:mainfrom
Ricardo-M-L:fix/local-bash-timeout-text

Conversation

@Ricardo-M-L

@Ricardo-M-L Ricardo-M-L commented Oct 31, 2026 •

Copy link
Copy Markdown

Problem

With --enable_local_env, a Bash command that times out returns TimeoutExpired.stdout directly. Python retains this as bytes even when subprocess.run(text=True) was requested. The local controller therefore changes the type of output on timeout, json.dumps(result) fails with TypeError, and partial stderr (often the useful failure diagnostic) is lost.

For example, a bounded Bash script that prints to both streams and then loops returns a byte-valued stdout and no stderr before this change.

Fix

Decode captured timeout bytes with the subprocess's locale text encoding and errors="replace" (a timeout may cut a character mid-write), then combine stdout and stderr just as the completed-process path does. Already-text and missing captures are preserved. Status, return code, timeout and error metadata are unchanged; no execution-policy or Python-runner changes.

Verification

  • Added six stdlib-only unittest cases: JSON serialization, both streams, locale decoding, incomplete byte sequences, text/None captures, a real bounded Bash timeout, and normal/nonzero completion controls (some are subtests).
  • On the unchanged production source the timeout regressions fail; notably the real process returns b'stdout' instead of text containing both streams.
  • Final focused suite: 6 passed, repeated in three additional independent runs.
  • Entire tests/ discovery: 11 passed using Python 3.12 with the provider tests' lightweight imports (numpy, backoff, anthropic, openai). No API/model calls.
  • black --check gui_agents agent_s4 passes (136 files), touched test formatting and git diff --check pass.

Commands:

python -m unittest discover -s tests -p test_local_env.py -v
python -m unittest discover -s tests -v
black --check gui_agents agent_s4 tests/test_local_env.py

The real Bash case is skipped when /bin/bash is absent; no Windows integration execution is claimed. No model/OCR dependencies were downloaded for these checks.

AI assistance: Codex helped implement and repeatedly verify this focused fix. Duplicate search included existing local-execution hardening #209, whose timeout branch still returns the same raw bytes; this patch does not add its Docker/execution-policy features.

Hosted validation status — 2026-11-01

The lint workflow is action_required for this fork. The local test/format results above do not imply hosted CI passed. Could a maintainer approve the workflow when reviewing this fix?

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