[FEATURE] Auto-archive (auto-close tab) for scheduled task / routine run sessions after completion
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":
- The tool always requires a manual confirmation click, even though scheduled runs execute with
permissionMode: bypassPermissions(andchromePermissionMode: skip_all_permission_checks). - Clicking Allow is never persisted: the session's
alwaysAllowedReasons/sessionPermissionUpdatesstay empty and noapprovedPermissionsentry is written to the task inscheduled-tasks.json— so the next unattended run prompts again. - Pre-seeding
{"toolName": "mcp__ccd_session_mgmt__archive_session"}into the task'sapprovedPermissions(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
approvedPermissionsentry forarchive_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)
Showing cached comments. Read the full discussion on GitHub ↗
3 Comments
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.
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_sessionspull 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_sessionsreturns roughly 88k characters atlimit: 250and 160k atlimit: 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
approvedPermissionsentry forarchive_sessionstill prompts. The same holds one layer up.~/.claude/settings.jsonhere contains:and every
archive_sessioncall 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:
archive_sessionbe pre-authorized like other MCP tools, or add a bulkarchive_sessions(session_ids[])that takes one approval for the batch.Happy to supply the raw counts if they're useful.
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_triggeroperate on routines, not runs.last_run, a single entry. The rest of thehistory isn't enumerable.
cse_...).list_sessionsexcludestrigger-fired runs by default, and its
tagsfilter returnstags filter is not currently availablefor in-session callers — so theruns can't even be listed, let alone deleted.
Requests, roughly in order of usefulness
older runs pruned automatically. This alone solves it.
create_triggerconfig-complete — sources, model, outcomebranches, allowed_tools. Independently useful, and it would at least make
the clone-and-delete workaround real.
Environment
Claude Code on the web (
web_claude_aiorigin), container CC 2.1.259,anthropic_cloudenvironment. Routines created in the web UI, fired on a0 3 * * *cron since 2026-04-27.