[FEATURE] Auto-archive (auto-close tab) for scheduled task / routine run sessions after completion

Status Open
Maintainer reply None cached
Activity 6 comments · opened Jul 6, 2026

Feature request

An opt-in way for scheduled task (routine) run sessions to auto-archive — i.e. close their own tab — once the run completes.

Use case

I run an hourly monitoring routine in the desktop app (cron 0 0,4,8-23 * * * ≈ 18 runs/day). Every run opens a session tab that stays open forever, so the tab bar fills up with identical completed-run tabs and I have to close them by hand every day. Any high-frequency routine has this problem.

What I tried (all dead ends, seemingly by design)

Adding a final step to the task prompt that calls mcp__ccd_session_mgmt__archive_session with session_id: "self":

  1. The tool always requires a manual confirmation click, even though scheduled runs execute with permissionMode: bypassPermissions (and chromePermissionMode: skip_all_permission_checks).
  2. Clicking Allow is never persisted: the session's alwaysAllowedReasons / sessionPermissionUpdates stay empty and no approvedPermissions entry is written to the task in scheduled-tasks.json — so the next unattended run prompts again.
  3. Pre-seeding {"toolName": "mcp__ccd_session_mgmt__archive_session"} into the task's approvedPermissions (verified loaded after app restart and preserved across store flushes) still prompts — the confirmation sits outside the task-approval layer that works fine for e.g. Chrome MCP tools.

Worse, an unattended run stalls indefinitely on that dialog (observed 30+ min), holding the per-task scheduler slot, so the next hourly fire is skipped with per_task_limit. So today the safe options are: leave the tabs, or close them manually.

Suggested shape (any of these would work)

  • A per-task option — task config / SKILL.md frontmatter or the task edit UI: "Archive session when run completes" (default off), or
  • a Settings preference next to Auto-archive on PR close: "Auto-archive completed scheduled-task runs (after N hours)", or
  • honor a task-level approvedPermissions entry for archive_session(self) in scheduled runs only.

Session state already carries an autoArchiveExempt flag (set when the user interacts with a session), which suggests part of the infrastructure exists.

Related

  • #69639 (bulk archive for sessions — complementary, this request is about not needing the bulk cleanup in the first place)
  • #67615 (same hard-confirm-in-bypass-mode behavior family, for send_message)

Environment

  • Claude desktop app 1.18286.0, macOS (Darwin 25.5.0)

View original on GitHub ↗

3 Comments

hahoheli · 3 months ago

I also have this issue. I have avoided running as many routines as my colleague - his computer started failing and I would not be surprised if it was due to the active running sessions from all routines he's got setup.

The routine feature is great - I really love the concept - I'm just feeling it is a unpolished diamond - and this type of fix would polish it alot for me.

geokao · 1 month ago

Adding a scale data point and one mechanism detail I don't think is in this thread yet.

Scale. I run 93 scheduled tasks on the desktop app (macOS). A list_sessions pull this week returned 453 sessions, 421 of them completed routine runs — 404 of those idle more than a day, the oldest 65 days. Nothing was deleted or misconfigured; that is what about two months of a normal routine fleet accumulates. The 18-runs/day case in the original report is the small version of this.

It also breaks the assistant's own session tooling. At that many live sessions, mcp__ccd_session_mgmt__list_sessions returns roughly 88k characters at limit: 250 and 160k at limit: 1000, both past the tool-result token cap, so the result is written out to a file instead of returned in context. The documented triage workflow (list → rank → archive) can't run in context at all once a routine fleet has been going for a couple of months.

New mechanism detail — the user-level allowlist doesn't reach it either. This issue already establishes that a task-level approvedPermissions entry for archive_session still prompts. The same holds one layer up. ~/.claude/settings.json here contains:

"permissions": { "allow": ["mcp__ccd_session_mgmt__*"], "defaultMode": "auto" }

and every archive_session call still prompts. The dialog says so itself — "This tool requires explicit approval regardless of permission mode" — and offers only Deny and Allow once, with no "always" option. So neither the task-approval layer nor the user settings allowlist touches it.

Consequence for a backlog that already exists. With no bulk form and no allowlist path, clearing an accumulated fleet costs one human click per session. I archived 51 by hand before stopping, with 353 left. An auto-archive setting fixes the future and leaves the existing ~400 untouched.

So there are two asks here:

  1. The retention / auto-archive setting proposed above. Every routine fleet accumulates this way, so I'd argue it should ship on by default.
  2. A way to clear a backlog that already exists: either let archive_session be pre-authorized like other MCP tools, or add a bulk archive_sessions(session_ids[]) that takes one approval for the batch.

Happy to supply the raw counts if they're useful.

beanqueen · 1 month ago

Cloud Routines: no way to prune run history, and no viable workaround

Summary

A recurring Routine accumulates run history indefinitely. There is no bulk
delete in the UI and no API path at all. On a routine that has fired daily
since April, the only option is clicking away several hundred runs one at a
time. In practice only the latest one or two runs are ever useful for me.

What's missing

No way — UI or API — to delete a Routine's old runs. Concretely, from an
agent session:

  • list_triggers / delete_trigger operate on routines, not runs.
  • A routine record exposes only last_run, a single entry. The rest of the

history isn't enumerable.

  • Routine runs are separate sessions (cse_...). list_sessions excludes

trigger-fired runs by default, and its tags filter returns
tags filter is not currently available for in-session callers — so the
runs can't even be listed, let alone deleted.

  • There is no delete-run / purge-history tool.

Requests, roughly in order of usefulness

  1. Retention setting per routine — "keep last N runs" (N=1,2,5,10) with

older runs pruned automatically. This alone solves it.

  1. Bulk-delete in the UI — select-all / "delete runs older than <date>".
  2. API parity for run history — a way to list and delete a routine's runs.
  3. Make create_trigger config-complete — sources, model, outcome

branches, allowed_tools. Independently useful, and it would at least make
the clone-and-delete workaround real.

Environment

Claude Code on the web (web_claude_ai origin), container CC 2.1.259,
anthropic_cloud environment. Routines created in the web UI, fired on a
0 3 * * * cron since 2026-04-27.

Showing cached comments. Read the full discussion on GitHub ↗