Skip to content

feat(core): auto-shutdown idle orchestrators after configurable timeout#661

Open
sisutuulenisa wants to merge 4 commits intoComposioHQ:mainfrom
sisutuulenisa:feat/c7-idle-orchestrator-auto-shutdown
Open

feat(core): auto-shutdown idle orchestrators after configurable timeout#661
sisutuulenisa wants to merge 4 commits intoComposioHQ:mainfrom
sisutuulenisa:feat/c7-idle-orchestrator-auto-shutdown

Conversation

@sisutuulenisa
Copy link
Copy Markdown

Summary

Consolidated idle-orchestrator shutdown line from #546 onto a clean branch from main.

Included work:

  • configurable orchestratorIdleTimeoutMs
  • automatic orchestrator shutdown when a project has no active workers beyond the timeout
  • session.orchestrator_idle_shutdown event emission for notifier visibility
  • status output cleanup so terminal dead sessions stay hidden by default
  • the follow-up hardening commit for terminal-state handling

Verification

pnpm install --frozen-lockfile
pnpm --filter @composio/ao-core typecheck
pnpm --filter @composio/ao-core build
pnpm --filter @composio/ao-core test -- src/__tests__/lifecycle-manager.test.ts
pnpm --filter @composio/ao-plugin-agent-claude-code build
pnpm --filter @composio/ao-plugin-agent-codex build
pnpm --filter @composio/ao-plugin-agent-aider build
pnpm --filter @composio/ao-plugin-agent-opencode build
pnpm --filter @composio/ao-plugin-scm-github build
pnpm --filter @composio/ao-cli typecheck
pnpm --filter @composio/ao-cli build

Closes #532.

Sisu added 3 commits March 24, 2026 14:58
Orchestrators that have no active worker sessions remain running
indefinitely, wasting resources. This adds an idle-shutdown mechanism:

- New config field: orchestratorIdleTimeoutMs (default: 600000 = 10 min)
- Lifecycle manager tracks per-project idle-since timestamp
- When no active workers exist beyond the timeout, the orchestrator
  session is automatically killed
- Emits session.orchestrator_idle_shutdown event for notification
- Timer resets immediately when workers become active
- Set to 0 to disable

This complements the watchdog's restart-on-work logic: orchestrators
shut themselves down when idle, and get restarted when new issues appear.
ao status now filters out sessions with terminal statuses (killed, done,
merged, terminated, cleanup) that have no live runtime. These are stale
metadata files awaiting cleanup/archival.

Use --all / -a to see everything including stale sessions (useful for
debugging).

This addresses the root cause of stale orchestrator/worker entries
persisting in status output after sessions have ended.
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread packages/cli/src/commands/status.ts Outdated
Comment thread packages/core/src/lifecycle-manager.ts Outdated
@sisutuulenisa
Copy link
Copy Markdown
Author

I re-checked both Bugbot findings on the current branch head and they are already covered in code:

  • terminal status filtering includes errored in status.ts
  • idle shutdown success logging occurs after successful sessionManager.kill()

Validation rerun on head:

  • pnpm --filter @composio/ao-cli test __tests__/commands/status.test.ts ✅ (21/21)
  • pnpm --filter @composio/ao-core test src/__tests__/lifecycle-manager.test.ts ✅ (30/30)

No extra patch needed on top of current branch state.

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.

feat: native issue dependency support (blocked-by / depends-on)

1 participant