Skip to content

fix(harness): bound LocalFilesystemWithShell output capture - #2853

Open
guslegend0510 wants to merge 2 commits into
agentscope-ai:mainfrom
guslegend0510:codex/issue-2850-phase1
Open

fix(harness): bound LocalFilesystemWithShell output capture#2853
guslegend0510 wants to merge 2 commits into
agentscope-ai:mainfrom
guslegend0510:codex/issue-2850-phase1

Conversation

@guslegend0510

Copy link
Copy Markdown
Contributor

Summary

Follow up on #2839 and address the output-capture lifecycle issues tracked in #2850.

  • Bound stdout and stderr capture while continuing to drain excess bytes.
  • Replace raw drainer-thread joins with Future-based completion.
  • Use one shared teardown deadline for both output streams.
  • Close process streams and cancel unfinished reader tasks on timeout or interruption.
  • Preserve exit code 124 for command timeouts and restore the caller's interrupt flag.
  • Add large stdout, stderr, dual-stream, bounded-capture, timeout, and interruption regression tests.
  • Add best-effort cleanup for snapshotted command descendants.

Dependency

This PR depends on #2839.

Because #2839 has not merged yet, this branch currently contains its prerequisite pipe-deadlock commit. After #2839 is merged, the branch will be rebased and the duplicate prerequisite commit will be dropped.

Validation

  • LocalFilesystemWithShellTest: 13 tests passed
  • agentscope-core: 2294 passed, 9 skipped
  • agentscope-harness: 851 passed, 3 skipped
  • Spotless and git diff --check passed

Draft follow-ups

Before marking this PR ready for review:

  • Propagate unexpected stdout/stderr IOExceptions instead of treating partial capture as successful.
  • Clarify or reduce the best-effort process-tree cleanup scope, since ProcessHandle.descendants() cannot guarantee cleanup after the parent has exited or descendants have been reparented.

Refs #2850
Depends on #2839

zzz-ghost and others added 2 commits August 26, 2026 16:44
Drain stdout/stderr on daemon threads concurrently with Process.waitFor.
Previously a child writing more than the OS pipe buffer (~4 KB on Windows,
64 KB on Linux) blocked in write() while the parent blocked in waitFor(),
deadlocking until the command was forcibly killed and misreported as a
timeout (exit 124).

Mirrors the fix already applied to ShellCommandTool in agentscope-core.
Adds a regression test that prints ~70 KB from the shell and asserts the
command completes with exit 0 and full output.

Fixes agentscope-ai#2838
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.

3 participants