Shell Session Hooks¶
The scripts/session_hooks.sh script exposes two functions for lightweight
session logging:
codex_session_start [argsβ¦]β record the start of a shell session.codex_session_end [exit_code]β record the end of a session and exit code.
Both functions rely on a small Python snippet to append newline-delimited JSON
entries to the directory indicated by CODEX_SESSION_LOG_DIR (default
.codex/sessions). After each Python call the script checks the exit status. If
logging fails, an error message is written to stderr but the calling shell
continues.
Example:
The start hook stores the current time so that the end hook can compute and record the session duration in seconds. Both hooks are best-effort and will not abort the main script when logging errors occur.