Skip to content

Scheduled Tasks: auto-close session after task completion #35280

Description

@jakobwechselberger

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestplatform:windowsIssue specifically occurs on WindowsstaleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions