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
UserPromptSubmit and SessionStart hooks fire simultaneously on first prompt #15266
When both SessionStart and UserPromptSubmit hooks are registered, they fire simultaneously on the first prompt. On subsequent prompts, only UserPromptSubmit fires (expected).
Expected behavior
SessionStart should complete before UserPromptSubmit fires on the first prompt, or they should not overlap — since the first prompt is both a session start event and a prompt submit event.
I've prepared a fix for this in branch mvanhorn:fix/session-start-hook-timing.
The fix fires SessionStart hooks eagerly during session creation (right after SessionConfigured is emitted) instead of deferring them to the first turn. The hook outcome (should_stop + additional_contexts) is stored on SessionState and consumed by the first turn, preserving the existing context injection behavior while fixing the timing.
Key changes:
hook_runtime.rs: new run_session_start_hooks_eager() fires hooks at init time using send_event_raw (no TurnContext needed)
hook_runtime.rs: run_pending_session_start_hooks() checks for a stored eager outcome before falling back to deferred execution
state/session.rs: new EagerSessionStartHookOutcome type and field
codex.rs: session init calls eager hooks instead of setting pending_session_start_source
@abhinav-oai and I had a chance to look at this, and SessionStarts do run before UserPromptSubmits. They still wait for the first prompt as the official start of session, but ordering is enforced. So the practical way to test that is to put a sleep into a SessionStart hook, and notice that the UserPromptSubmit hooks don't run until that sleep is complete. So I think this works
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.
why would SessionStart not fire when the agent is ready to receive input (a valid use case we have and want this event for)? UserPromptSubmit is the event that gets triggered on you guessed it, the moment a user submits a prompt. So imo it's completely missing the goal when those timings are the same?
Claude Code does it correct, so why not honor the same?
Activity
fix(hooks): fire SessionStart hook at session creation, not first prompt
mvanhorn commentedon Mar 20, 2026
I've prepared a fix for this in branch
mvanhorn:fix/session-start-hook-timing.The fix fires
SessionStarthooks eagerly during session creation (right afterSessionConfiguredis emitted) instead of deferring them to the first turn. The hook outcome (should_stop+additional_contexts) is stored onSessionStateand consumed by the first turn, preserving the existing context injection behavior while fixing the timing.Key changes:
hook_runtime.rs: newrun_session_start_hooks_eager()fires hooks at init time usingsend_event_raw(noTurnContextneeded)hook_runtime.rs:run_pending_session_start_hooks()checks for a stored eager outcome before falling back to deferred executionstate/session.rs: newEagerSessionStartHookOutcometype and fieldcodex.rs: session init calls eager hooks instead of settingpending_session_start_sourceBuilds cleanly with
cargo check -p codex-core. Branch is at https://github.com/mvanhorn/codex/tree/fix/session-start-hook-timing(PR creation is blocked by org OAuth policy - will submit via web UI.)
eternal-openai commentedon Apr 10, 2026
@abhinav-oai and I had a chance to look at this, and SessionStarts do run before UserPromptSubmits. They still wait for the first prompt as the official start of session, but ordering is enforced. So the practical way to test that is to put a sleep into a SessionStart hook, and notice that the UserPromptSubmit hooks don't run until that sleep is complete. So I think this works
feat(codex): first-class hook surface — header, badge, auto-update
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.
Morriz commentedon May 14, 2026
why would SessionStart not fire when the agent is ready to receive input (a valid use case we have and want this event for)? UserPromptSubmit is the event that gets triggered on you guessed it, the moment a user submits a prompt. So imo it's completely missing the goal when those timings are the same?
Claude Code does it correct, so why not honor the same?
Morriz commentedon May 14, 2026
can we re-open this please @eternal-openai ?
feat(hooks): scaffold hook pipeline — dispatch + state store + bundle…
feat(handler): SessionStart auto-start via idempotent session-bootstrap
feat(handler): UserPromptSubmit — off-record gate + race-safe bootstrap
Add Codex integration: hooks, permissions, session lifecycle
fix(history): a new Codex pane is not blamed on the Herdr integration (…