Skip to content

fix(run): grace period before exit for multi-background-agent race#5

Merged
ranxianglei merged 2 commits into
masterfrom
fix/run-grace-period-multi-bg
Jun 25, 2026
Merged

fix(run): grace period before exit for multi-background-agent race#5
ranxianglei merged 2 commits into
masterfrom
fix/run-grace-period-multi-bg

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Background sessions spawned near the main session's completion emit their busy event asynchronously, so busy was momentarily empty when main went idle — done resolved prematurely and process.exit killed agents not yet tracked. Wait a 3s grace period once everything appears idle before resolving done; any session going busy during it cancels the grace. Verified: 3 parallel background agents all complete (finish=stop), clean EXIT=0.

e-cigarettes and others added 2 commits June 24, 2026 14:25
done resolved the instant mainIdle && busy.size === 0. With multiple
background agents, those spawned near the main session's completion
emit their busy event asynchronously (omo-stable fires prompt without
await), so busy was momentarily empty when main went idle. done
resolved prematurely and the fallback process.exit killed agents that
hadn't been tracked yet — the first agent finishing would take the
whole process down.

Wait a 3s grace period once everything appears idle before resolving
done. Any session going busy during the grace period cancels it, so
late-spawned background agents are picked up. Verified with 3 parallel
background agents: all complete (finish=stop), clean EXIT=0.
@ranxianglei ranxianglei merged commit 86379fc into master Jun 25, 2026
3 of 8 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@ranxianglei ranxianglei deleted the fix/run-grace-period-multi-bg branch June 25, 2026 13:26
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants