Feature request: native cleanup tool for outdated automation runs

Open 💬 2 comments Opened Jun 20, 2026 by tsubasakong
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What problem would this solve?

Codex automations can create many completed runs and, for worktree-backed project automations, many associated worktrees over time. The current documented guidance is to archive automation runs no longer needed, but there does not appear to be a first-class, metadata-backed tool/API that can safely apply a retention policy to completed automation runs.

Today, a cleanup automation has to approximate this by listing recent Codex threads and calling set_thread_archived on known thread IDs. That is brittle because it requires inferring automation ownership and eligibility from thread titles/previews/status rather than structured automation metadata.

Requested feature

Please add a native Codex tool/API for cleaning outdated automation-created runs/tasks.

It should support:

  • Listing automation-created runs with structured fields such as automation_id, created_at, updated_at, status, pinned, archived, ownership/source, and associated worktree state.
  • Dry-run mode that returns exactly which runs would be archived/deleted and why others were skipped.
  • Applying a retention policy, for example archive completed automation runs older than 24 hours or 7 days.
  • Default exclusions for active/running runs, pinned runs, user-owned conversational threads, non-automation threads, the current cleanup run, and ambiguous matches.
  • Structured results with archived/skipped/error counts and per-run reasons.
  • Ideally per-automation retention settings, so high-frequency automations can clean themselves safely.

Current workaround

A recurring cleanup automation can use list_threads and set_thread_archived, but it must be conservative and skip anything whose age, completion state, or automation ownership is unclear. This avoids accidental archival but leaves stale automation runs behind and makes cleanup logic fragile.

Why this matters

The Codex app already documents that frequent automations can create many worktrees over time and recommends archiving runs that are no longer needed. A dedicated cleanup tool would make that recommendation practical and safe for recurring automations without relying on title/preview inference.

View original on GitHub ↗

2 Comments

github-actions[bot] contributor · 2 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #28922
  • #28329
  • #28187

Powered by Codex Action

cyq1017 · 1 month ago

Adding one user-facing cleanup angle that is adjacent to the API/tool request here.

For high-frequency recurring automations, the immediate pain is not only safe metadata-backed cleanup from code. It is also project-sidebar management after many automation-created threads already exist.

Useful UX additions would be:

  • Group automation-created threads/runs under their parent automation instead of mixing every run into the main project conversation list.
  • Add bulk actions scoped to one automation, for example archive/delete all completed runs for this automation, with pinned/running/manual threads excluded by default.
  • When an automation is paused or deleted, offer an explicit cleanup step such as archive historical completed runs, keep latest N runs, or leave history untouched.
  • Provide per-automation retention controls in the UI, e.g. keep latest 5 successful runs, auto-archive successful runs after 7 days, always keep failed/action-required runs.
  • Show a dry-run/preview before destructive cleanup so users can see exactly which threads/runs will be affected.

This would make recurring automations practical for long-lived projects without requiring users to manually archive many duplicate-looking sidebar entries or delete internal files directly.