Skip to content

fix(core): cleanup background bash processes so cli exits#45

Merged
Octane0411 merged 1 commit intomainfrom
fix/harbor-background-bash-exit
Mar 3, 2026
Merged

fix(core): cleanup background bash processes so cli exits#45
Octane0411 merged 1 commit intomainfrom
fix/harbor-background-bash-exit

Conversation

@Octane0411
Copy link
Collaborator

Summary

Fix an agent hang seen in terminal-bench runs where tasks complete in transcript but Harbor stays at running agent and never reaches verifier.

Root Cause

Bash tool background mode (run_in_background) left child process/pipe handles attached to the Node/Bun event loop, and CLI had no shutdown cleanup for background processes. In tasks like configure-git-webserver, this can keep oas alive after final answer.

Changes

  • packages/core/src/tools/bash.ts
    • unref background child process + stdio handles
    • add cleanupBackgroundProcesses() for best-effort termination on shutdown
  • packages/cli/src/index.ts
    • call cleanupBackgroundProcesses() in finally before exit
  • packages/core/src/tools/registry.ts and packages/core/src/index.ts
    • export cleanup helper
  • packages/core/tests/tools/bash-enhanced.test.ts
    • add regression test for background cleanup

Validation

  • bun test packages/core/tests/tools/bash-enhanced.test.ts
  • bun test packages/core/tests/tools/kill-bash.test.ts packages/core/tests/tools/bash-output.test.ts
  • bun run typecheck

All passed locally.

@Octane0411 Octane0411 force-pushed the fix/harbor-background-bash-exit branch from 0c8582b to edd62db Compare March 3, 2026 02:20
@Octane0411 Octane0411 merged commit 4e03dbe into main Mar 3, 2026
1 check passed
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