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
CLAUDE_CODE_SESSION_ID — the env var that would let ox hooks deterministically identify the Claude Code session that triggered them — is absent from the Bash tool env in recent Claude Code versions.
Also: CLAUDE_CODE_SESSION_ID is absent from the Bash tool env, same as #258 observed.
This was also noted in #258, suggesting the gap has existed across multiple ox release cycles — but it may be worth revisiting whether a recent Claude Code version change (the report saw 2.1.112) changed the env injection behavior in a way that now matters more than it did before.
Why it matters
Several ox code paths want to correlate a hook invocation with a specific claude session:
Session marker lookup — cmd/ox/agent_prime.go:180-189 keys idempotent-prime and session-state-reuse decisions on agentSessionID. When empty, the whole idempotent/marker code path is bypassed and other heuristics (ancestor PID match, sole-active-recording) take over.
Session capture-prior linking — the ox session verify design and the adapter protocol assume we can correlate raw.jsonl ↔ claude's session log. Without the env var, this has to fall back to time-window + project matching.
Confirm the env var is actually missing. Run Claude Code 2.1.x, add a hook that dumps its env to a temp file, verify CLAUDE_CODE_SESSION_ID is or isn't present.
Check across Claude Code versions. If older versions emitted it, identify the version that changed.
Check hook-type variation. Maybe SessionStart gets it (via stdin payload), but PostToolUse doesn't (only inherits process env).
If Claude Code no longer emits it, decide how ox discovers the session ID. Options:
Parse it from hook stdin payload (which Claude Code does send, per existing adapter code).
Walk up the process tree and match against ~/.claude/projects/**/<session-id>.jsonl by PID/timestamp.
Have ox agent prime persist the discovered session ID to a marker file at session start and have subsequent hooks read from there.
Root cause identified: is CLAUDE_CODE_SESSION_ID missing from all ox-invoked hooks in current Claude Code versions, or only some? Or is it present under a different name?
ox has a reliable way to get the claude session ID at hook time without relying on this env var, OR it's documented that ox requires a Claude Code version that still injects it.
Split out from #519.
Symptom
CLAUDE_CODE_SESSION_ID— the env var that would let ox hooks deterministically identify the Claude Code session that triggered them — is absent from the Bash tool env in recent Claude Code versions.From the report in #519:
This was also noted in #258, suggesting the gap has existed across multiple ox release cycles — but it may be worth revisiting whether a recent Claude Code version change (the report saw 2.1.112) changed the env injection behavior in a way that now matters more than it did before.
Why it matters
Several ox code paths want to correlate a hook invocation with a specific claude session:
cmd/ox/agent_prime.go:180-189keys idempotent-prime and session-state-reuse decisions onagentSessionID. When empty, the whole idempotent/marker code path is bypassed and other heuristics (ancestor PID match, sole-active-recording) take over.ox session verifydesign and the adapter protocol assume we can correlateraw.jsonl↔ claude's session log. Without the env var, this has to fall back to time-window + project matching.CLAUDE_CODE_SESSION_IDbut that var is never set, the recorder writes under one key and lookups by session ID never find it. This is one hypothesis for why PostToolUse hooks fire but never append toraw.jsonl.What to investigate
CLAUDE_CODE_SESSION_IDis or isn't present.~/.claude/projects/**/<session-id>.jsonlby PID/timestamp.ox agent primepersist the discovered session ID to a marker file at session start and have subsequent hooks read from there.Acceptance criteria
CLAUDE_CODE_SESSION_IDmissing from all ox-invoked hooks in current Claude Code versions, or only some? Or is it present under a different name?Related