Add a SessionStart hook (Claude parity) for pre-session script + context injection

Resolved 💬 1 comment Opened Feb 27, 2026 by thellimist Closed Feb 27, 2026

What variant of Codex are you using?

CLI, Codex App, Cursor Codex

What feature would you like to see?

Add a first-class SessionStart hook, equivalent to Claude Code's SessionStart behavior.

I need a deterministic hook that runs once at session start (before the first user prompt is processed), so I can:

  • run a local script
  • gather project/runtime context
  • inject that context into the session before normal turns continue

Why this matters

Current hooks are useful, but there is no explicit pre-session lifecycle point dedicated to one-time startup context hydration.

Without this, startup context workflows require wrappers/hacks and are not deterministic across session entry paths.

Proposed behavior

  1. Add a new event, for example: SessionStart
  2. Trigger exactly once per new session (not once per turn)
  3. Trigger before first model turn/user-prompt processing
  4. Make injection deterministic and explicit (e.g. additional context payload accepted by core)
  5. Ensure consistent behavior across:
  • codex interactive
  • codex exec
  • session resume/new-session paths (with clear policy)

Failure policy

Please make failure policy configurable, like other hooks:

  • continue on hook error
  • fail session start on hook error

Acceptance criteria

  • A configured SessionStart hook runs once at the beginning of a session.
  • Hook can return startup context that is injected before first turn.
  • Startup behavior is deterministic and documented.
  • Resume behavior is explicit (whether hook runs or not on resume).

Additional context

This is closely related to lifecycle hooks in #2109, but requesting an explicit dedicated pre-session hook with context injection semantics.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗