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
SessionStart (source: resume) fires only with the first prompt after /resume, and the replaced startup session gets SessionEnd without SessionStart #51360
CLIIssues related to the Codex CLIbugSomething isn't workinghooksIssues related to event hookssessionIssues involving session (thread) management, resuming, forking, naming, archiving
Configure SessionStart, UserPromptSubmit, and SessionEnd hooks that log hook_event_name, source, and session_id.
Start codex, then run /resume and pick an earlier conversation.
Wait, then send a prompt.
Expected: SessionStart with source: "resume" fires when the conversation is resumed, so integrations can show that conversation's state before the user types anything.
Actual
No hook fires on /resume. SessionStart (source: "resume") arrives in the same second as the first UserPromptSubmit; if no prompt is sent, it never fires.
The blank startup session that /resume replaced gets no SessionStart, yet its SessionEnd (reason: "other") arrives 60 seconds after /resume, while the resumed conversation is already mid-turn. A consumer that treats SessionEnd as "the agent in this terminal exited" tears down the live conversation's state.
Log (session truncated):
+0s SessionEnd session=01a11105-3861 reason=other ← replaced startup session, 60s after /resume
...
SessionStart source=resume session=01a110e4-52e2 ← only with the first prompt
UserPromptSubmit session=01a110e4-52e2
Ask: fire SessionStart (source: "resume") when /resume selects a conversation, and either pair the startup session's SessionEnd with a SessionStart or skip it for a session that never started a turn.
This timing matters for lightweight peer/status integrations: opening or resuming a Codex terminal should register it before the user sends a greeting solely to trigger hooks. SessionStart already exists and is wired in our harness; the needed guarantee is execution before first input.
Could the fix cover fresh interactive launch, direct codex resume <id> and in-TUI /resume, with the exact addressable thread ID? If fresh threads intentionally remain lazy, a frontend-ready event needs an explicit join to a supported addressable thread before the first model turn. The allowlisted originating-client client_env proposed in #44902 can carry a per-launch terminal marker; timing correlation between readiness and a later thread is insufficient with several terminals sharing one daemon and directory.
Please also distinguish replacing a thread from exiting its frontend. A delayed end for an unused startup thread must not unregister the resumed conversation in the same terminal; /clear needs equivalent behavior.
Evidence scope: this issue's report is 0.160.1 macOS in-TUI /resume. Our harness has older 0.155/0.156 direct-resume omissions and a 0.159.2 Windows lazy-thread observation. Our current Mac pair is CLI 0.161.0 plus daemon 0.162.0, but we have not completed a current-version pre-input hook-timing repro and are not claiming these reports prove it. This comment states the required behavior. Read-only interactive presence is the separate request in #35676.
On codex-cli 0.165.0 (macOS 27), a direct codex resume <thread-id> launch in a new terminal ran no SessionStart hook in the first 15 seconds. SessionStart ran when the first prompt was submitted. An integration that routes messages to a conversation using its SessionStart report cannot deliver messages to the resumed conversation until someone types into it.
Still reproducible on codex-cli 0.166.0, Linux x86_64 (WSL2), with the TUI attached to the shared app-server daemon. There is also one case that I don't think has been described here yet.
1. Direct codex resume <id>: no SessionStart until the first turn. With a hook that only records its input, SessionStart (source: "resume") was logged at the start of the first turn, together with the first UserPromptSubmit, and never while the resumed TUI sat idle. A turn started by a message queued with thread/queue/add (not by typing) also runs it at that point.
2. Resuming a thread that the daemon still has loaded: SessionEnd runs inside thread/resume.
Exit the TUI.
Run codex resume <id> before the daemon unloads the idle thread. In our environment, the unload happened about 60 s after exit; we resumed after 26–38 s.
In our attempts, the daemon then shut down the old run as part of the resume request, so SessionEnd ran before the new run was created. The new run had no SessionStart until its first turn. For an integration that registers in SessionStart and unregisters in SessionEnd, the resumed conversation is therefore unregistered from the moment of resume until someone types.
CLIIssues related to the Codex CLIbugSomething isn't workinghooksIssues related to event hookssessionIssues involving session (thread) management, resuming, forking, naming, archiving
Activity
NateChristiansen commentedon Oct 9, 2026
This timing matters for lightweight peer/status integrations: opening or resuming a Codex terminal should register it before the user sends a greeting solely to trigger hooks.
SessionStartalready exists and is wired in our harness; the needed guarantee is execution before first input.Could the fix cover fresh interactive launch, direct
codex resume <id>and in-TUI/resume, with the exact addressable thread ID? If fresh threads intentionally remain lazy, a frontend-ready event needs an explicit join to a supported addressable thread before the first model turn. The allowlisted originating-clientclient_envproposed in #44902 can carry a per-launch terminal marker; timing correlation between readiness and a later thread is insufficient with several terminals sharing one daemon and directory.Please also distinguish replacing a thread from exiting its frontend. A delayed end for an unused startup thread must not unregister the resumed conversation in the same terminal;
/clearneeds equivalent behavior.Evidence scope: this issue's report is 0.160.1 macOS in-TUI
/resume. Our harness has older 0.155/0.156 direct-resume omissions and a 0.159.2 Windows lazy-thread observation. Our current Mac pair is CLI 0.161.0 plus daemon 0.162.0, but we have not completed a current-version pre-input hook-timing repro and are not claiming these reports prove it. This comment states the required behavior. Read-only interactive presence is the separate request in #35676.liby commentedon Oct 28, 2026
On codex-cli 0.165.0 (macOS 27), a direct
codex resume <thread-id>launch in a new terminal ran noSessionStarthook in the first 15 seconds.SessionStartran when the first prompt was submitted. An integration that routes messages to a conversation using itsSessionStartreport cannot deliver messages to the resumed conversation until someone types into it.fix(restore): record a reopened conversation as its pane's occupant a…
hag03521 commentedon Nov 4, 2026
Still reproducible on codex-cli 0.166.0, Linux x86_64 (WSL2), with the TUI attached to the shared app-server daemon. There is also one case that I don't think has been described here yet.
1. Direct
codex resume <id>: noSessionStartuntil the first turn. With a hook that only records its input,SessionStart(source: "resume") was logged at the start of the first turn, together with the firstUserPromptSubmit, and never while the resumed TUI sat idle. A turn started by a message queued withthread/queue/add(not by typing) also runs it at that point.2. Resuming a thread that the daemon still has loaded:
SessionEndruns insidethread/resume.codex resume <id>before the daemon unloads the idle thread. In our environment, the unload happened about 60 s after exit; we resumed after 26–38 s.In our attempts, the daemon then shut down the old run as part of the resume request, so
SessionEndran before the new run was created. The new run had noSessionStartuntil its first turn. For an integration that registers inSessionStartand unregisters inSessionEnd, the resumed conversation is therefore unregistered from the moment of resume until someone types.Daemon log for case 2 (identifiers replaced)
The integration's
SessionEndhandler recorded the end at 08:45:01.587, inside this request.From reading
rust-v0.166.0app-server/src/request_processors/thread_processor.rs, our understanding (please correct us) is:resume_running_threadshuts the loaded thread down only when the resume overrides differ from the loaded thread; otherwise it rejoins.It would help integrations if:
SessionStart(source: "resume") ran when the resumed run is created, or Let integrations know which thread is active when it is opened, resumed, or reconnected, without waiting for a prompt #52907's observation surface existed.SessionEnd) versus rejoins it.