Scheduled Tasks: auto-close session after task completion

Resolved 💬 3 comments Opened Mar 17, 2026 by jakobwechselberger Closed Apr 22, 2026

Problem

Scheduled tasks leave their sessions open indefinitely after the agent finishes all work. The user must manually /exit or archive each session from the sidebar.

Running multiple daily cron tasks (smoke tests, imports, briefings) creates zombie sessions that need manual cleanup every morning.

Current behavior

  1. Scheduled task fires at cron time
  2. Agent completes all work (writes results to DB, no more actions needed)
  3. Session stays open in sidebar with spinning indicator
  4. User must manually close each completed session

Desired behavior

Sessions spawned by scheduled tasks should auto-terminate once the agent has no more work to do. Possible implementations:

  • autoClose: true frontmatter in SKILL.md — close session when agent stops generating
  • maxDuration: 300 frontmatter — timeout in seconds, session terminates after that
  • Built-in exit tool the agent can call to programmatically end its own session

Workaround attempted

Adding explicit "terminate immediately" instructions to the task prompt. The agent stops talking but the session remains open — this is a platform-level issue, not solvable via prompt.

Environment

  • Claude Code Desktop (Windows 11)
  • Multiple recurring cron tasks (daily smoke test, daily import, daily briefing)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗