You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add SessionEnd hook event for session/thread shutdown #20374
Codex has SessionStart but no symmetric SessionEnd hook. There is currently no reliable way to flush analytics, archive a transcript, or clean up scratch files when a session ends.
A SessionEnd hook that fires before a thread tears down, with a reason field that doubles as the dispatch matcher:
What do you mean by "session/thread shutdown"? New turns can be added to any thread — either immediately or after resuming. So there's really never any point where a thread "ends". If you're looking for a hook that fires when a turn ends, you can use the Stop hook.
What do you mean by "session/thread shutdown"? New turns can be added to any thread — either immediately or after resuming. So there's really never any point where a thread "ends". If you're looking for a hook that fires when a turn ends, you can use the Stop hook.
What i mean is that this hook should fire everytime we do a /exit or a ctrl+c to close codex
Here is an example of what Claude Code has:
A thread can be resumed after it "ended", but that does not mean that it was never ended in the first place, it ended and then resumed
This hook would be useful to do a bunch of operations like generating summaries, get information on the type of chat we had, and more
The /exit action really makes sense only for a TUI. Our other clients don't support a similar action. Hooks need to work across all surfaces, so I don't think this would make sense to add, at least not in this form.
The /exit action really makes sense only for a TUI. Our other clients don't support a similar action. Hooks need to work across all surfaces, so I don't think this would make sense to add, at least not in this form.
Yes i get the point, in my case i mostly use it in TUI, if something similar can be implemented everywhere it would be nice too
I can imagine calling the hook on command+q when closing the Codex app, ad example
Indexed this hook ticket in the umbrella tracker: #21753
Goal: collect the scattered Codex hook requests and bugs into one parity matrix for Full Claude Code Hook Parity (29+), while preserving this issue as the detailed thread for its specific behavior.
The /exit action really makes sense only for a TUI. Our other clients don't support a similar action. Hooks need to work across all surfaces, so I don't think this would make sense to add, at least not in this form.
Maybe instead of a /exit-specific hook, we could introduce more generic lifecycle hooks such as SessionAttach / SessionDetach.
Those events would map better across different surfaces (TUI, VSCode, Desktop, Web, etc.), while still allowing unsupported surfaces to simply ignore them if needed.
This would also be very useful for multitask workflows, where external tooling may want to monitor active threads/sessions, track which sessions are currently attached to a client, or perform cleanup/maintenance when the last client detaches.
i see this is not planned but i also see it referenced in this issue.
so should we expect this being added to codex sometime in the future @etraut-openai? a proper session end hook really helps power a lot of useful automation.
Activity
etraut-openai commentedon Apr 30, 2026
What do you mean by "session/thread shutdown"? New turns can be added to any thread — either immediately or after resuming. So there's really never any point where a thread "ends". If you're looking for a hook that fires when a turn ends, you can use the Stop hook.
matteomekhail commentedon May 1, 2026
What i mean is that this hook should fire everytime we do a /exit or a ctrl+c to close codex
Here is an example of what Claude Code has:

A thread can be resumed after it "ended", but that does not mean that it was never ended in the first place, it ended and then resumed
This hook would be useful to do a bunch of operations like generating summaries, get information on the type of chat we had, and more
etraut-openai commentedon May 1, 2026
The
/exitaction really makes sense only for a TUI. Our other clients don't support a similar action. Hooks need to work across all surfaces, so I don't think this would make sense to add, at least not in this form.matteomekhail commentedon May 1, 2026
Yes i get the point, in my case i mostly use it in TUI, if something similar can be implemented everywhere it would be nice too
I can imagine calling the hook on command+q when closing the Codex app, ad example
oxysoft commentedon May 8, 2026
Indexed this hook ticket in the umbrella tracker: #21753
Goal: collect the scattered Codex hook requests and bugs into one parity matrix for Full Claude Code Hook Parity (29+), while preserving this issue as the detailed thread for its specific behavior.
lowlandsheperd commentedon May 15, 2026
Maybe instead of a /exit-specific hook, we could introduce more generic lifecycle hooks such as SessionAttach / SessionDetach.
Those events would map better across different surfaces (TUI, VSCode, Desktop, Web, etc.), while still allowing unsupported surfaces to simply ignore them if needed.
This would also be very useful for multitask workflows, where external tooling may want to monitor active threads/sessions, track which sessions are currently attached to a client, or perform cleanup/maintenance when the last client detaches.
idodekerobo commentedon May 24, 2026
i see this is not planned but i also see it referenced in this issue.
so should we expect this being added to codex sometime in the future @etraut-openai? a proper session end hook really helps power a lot of useful automation.
docs: guide agents to leave the machine clean, document a SessionEnd …
docs: guide agents to leave the machine clean, document a SessionEnd …