Skip to content

fix(orchestration): release completed worker terminals by default - #16217

Closed
sanshengai wants to merge 1 commit into
stablyai:mainfrom
sanshengai:perf/release-completed-orchestration-workers
Closed

sanshengai wants to merge 1 commit into
stablyai:mainfrom
sanshengai:perf/release-completed-orchestration-workers

Conversation

@sanshengai

Copy link
Copy Markdown

Summary

  • schedule exact owned-worker terminal cleanup 30 seconds after an accepted succeeded/failed worker_done
  • preserve immediate exact-terminal reuse plus explicit retain, user takeover, transferred/external terminals, and unproven identities
  • rebuild pending automatic-release timers after startup/provider reconnect and reuse the existing durable archive + exact-close recovery pipeline
  • update the orchestration guide and bundled guide artifact

Why

Completed orchestration workers currently remain live until every coordinator explicitly calls worker-release. In multi-agent runs that omission accumulates idle agent processes, MCP subprocesses, and memory. The runtime already has a conservative exact-identity release pipeline; this change makes settled owned workers enter it by default after a short reuse window.

Fixes #13047
Related performance umbrella: #16211

Safety

  • no broad process-tree kill or terminal-title matching
  • active, reused, user-owned, externally owned, transferred, stopped/abandoned, and identity-unproven workers are retained
  • provider-unreachable/uncertain closes remain pending or unknown for existing recovery
  • worker/task outcomes are settled before cleanup and are not changed by cleanup failure

Validation

  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/rpc/methods/orchestration-worker-release.test.ts src/main/runtime/rpc/methods/orchestration-worker-release-recovery.test.ts src/main/runtime/rpc/methods/orchestration-send.test.ts src/main/runtime/rpc/methods/orchestration-federation-lifecycle-settlement.test.ts — 113 passed
  • pnpm exec oxlint ...changed TypeScript files...
  • pnpm run typecheck:node
  • pnpm run verify:bundled-skill-guides
  • pnpm run verify:skill-bundle-manifest
  • pnpm run check:max-lines-ratchet
  • git diff --check

pnpm test itself cannot load the optional windows-native-registry native module under the local Node 24.19.0 environment, so the same repository Vitest config was invoked directly for the focused suites.

AI assistance

This contribution was developed with AI assistance and manually reviewed against the terminal-ownership, federation, restart-recovery, and exact-process safety contracts.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3daa5f4e-b584-47be-8ffe-fc76db30f06b

📥 Commits

Reviewing files that changed from the base of the PR and between 4ee41fe and 8fa5bc7.

📒 Files selected for processing (9)
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/orchestration/automatic-worker-terminal-release.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-listing.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-release.ts
  • src/main/runtime/rpc/methods/orchestration-federation-relay.ts
  • src/main/runtime/rpc/methods/orchestration-worker-release-recovery.test.ts
  • src/main/runtime/rpc/methods/orchestration.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The runtime now detects settled worker terminals that remain owned and schedules release after a 30-second grace period. It rebuilds timers during recovery, suppresses duplicate timers, preserves explicit user retention, and cancels release when a terminal is reused. Lifecycle reconciliation and federation acknowledgments trigger scheduling. Database failures are logged without propagation. Documentation and tests cover the new behavior.

Merge Risk: ⚪ Minimal · up to 8fa5b

The change enables delayed cleanup of completed worker terminals while preserving reuse and ownership safeguards; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, rationale, linked issue, safety, and validation, but omits required Visual Proof, Testing, Review, boundary, Notes, and Checklist sections. Use the repository template headings; add Visual Proof with N/A and a reason, Testing details, Review, boundary, Notes, and completed checklist items.
Linked Issues check ⚠️ Warning The PR implements cleanup for settled worker_done terminals, but does not show migration or reclamation for legacy_ambiguous or abandoned workers required by [#13047]. Add code and tests for settled abandoned workers and legacy_ambiguous terminals, or provide a compliant reclaim path that preserves identity safety.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the primary change: automatic release of completed orchestration worker terminals.
Out of Scope Changes check ✅ Passed All listed code, documentation, runtime, database, RPC, and test changes support the linked automatic worker-terminal cleanup objective.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sanshengai

Copy link
Copy Markdown
Author

Closing as stale. main has moved on substantially since this branch was opened on Aug 24, and I am no longer following it. Happy to reopen a rebased, single-change PR if maintainers still want the fix.

@sanshengai sanshengai closed this Sep 11, 2026
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.

[Bug]: Orchestration worker terminals stay open after settle (Done stack / retained legacy_ambiguous) — no auto-release

1 participant