Feature request: before-archive hook for session closeout tasks

Open 💬 0 comments Opened Jun 11, 2026 by sumaomao1414

Summary

Please add a before-archive / closeout hook for Codex sessions, especially in Codex App, so agents can run project-specific cleanup before a conversation is archived.

Problem

When a user clicks the archive button in Codex App, the agent usually cannot intercept that UI action. This can leave project-level workflow state unfinished. For example, in an OpenSpec-driven project, a session may be archived while the related OpenSpec change remains active and unarchived.

Requested behavior

When the user archives a session, Codex should optionally detect whether the current session has associated closeout tasks and ask for confirmation before completing the archive.

For an OpenSpec workflow, the flow could be:

  1. User clicks the session archive button.
  2. Codex checks whether this session touched an OpenSpec change.
  3. Codex offers options such as:
  • Run OpenSpec closeout, then archive session
  • Archive session only
  • Cancel archive
  1. If the user chooses closeout, Codex can run project-specific commands such as:
  • openspec status --change "<name>" --json
  • validation commands
  • OpenSpec archive when tasks are complete
  1. If tasks are incomplete or validation fails, Codex should show the remaining work and allow the user to cancel session archival.

Generalization

This would be useful as a general before archive hook, not only for OpenSpec. Other examples:

  • run final tests or validation
  • generate a task summary
  • check uncommitted changes
  • archive or close external workflow items
  • update project tracking artifacts

Why it matters

A session archive is often treated by users as “this task is done.” If project-level state remains open, it creates drift between Codex session state and repository workflow state. A before-archive hook would give agents a final chance to make the repository state match the conversation state.

View original on GitHub ↗