Bug
When cozempic guard --daemon is invoked with an explicit --session <uuid> flag (as the SessionStart hook does via ${SESSION_ID:+--session $SESSION_ID}), the daemon starts, immediately prints ERROR: Could not detect current session, and exits — leaving a stale PID file behind and providing zero protection.
Note: I had Claude write this issue for me. I don't really understand enough about what's going on to file it myself, just that I got caught again this morning with the "Extra usage is required for long context requests" warning and asked omp/Claude to diagnose and fix it.
Environment
- cozempic 1.6.18
- macOS 26.1 Tahoe (Mac Mini M4)
- Oh My Pi coding harness (omp/14.1.0) — hooks fire correctly but guard always dies
Reproduction
The cozempic init-generated SessionStart hook runs:
cozempic guard --daemon --session <uuid> --cwd /path/to/project
This fails every time. Log output:
--- Guard daemon started at 2026-04-11T08:48:28 ---
CWD: /Users/bdwelle/lib/foilfinder
CMD: python3 -m cozempic.cli guard --cwd /Users/bdwelle/lib/foilfinder --threshold 50.0 --interval 30 -rx standard --session <uuid>
ERROR: Could not detect current session.
Contrast: working invocation
Running without --session from the same directory succeeds — the daemon auto-detects the correct session ID and starts the 4-tier guard:
cozempic guard --daemon --threshold 50 -rx standard --interval 30
4-tier guard protecting context (200K window):
Soft (25%): gentle prune, no reload
Hard1 (55%): standard prune + reload
Hard2 (80%): aggressive prune + reload
Hard3 (90%): manual aggressive
Impact
The SessionStart hook is the entire auto-protection mechanism. When --session breaks the daemon, every session silently goes unguarded. In our case: 66 consecutive guard processes spawned across multiple days, all dead on arrival, all leaving stale PID files in /tmp.
Workaround
Remove the explicit --session injection from the hook — replace:
cozempic guard --daemon ${SESSION_ID:+--session $SESSION_ID}
with:
Guard auto-detects the session correctly when left to its own devices.
Suggested fix
Either:
- Fix
guard --session <uuid> to resolve the session file path the same way auto-detection does, or
- Have
cozempic init not inject --session into the hook (auto-detection already works)
Bug
When
cozempic guard --daemonis invoked with an explicit--session <uuid>flag (as theSessionStarthook does via${SESSION_ID:+--session $SESSION_ID}), the daemon starts, immediately printsERROR: Could not detect current session, and exits — leaving a stale PID file behind and providing zero protection.Note: I had Claude write this issue for me. I don't really understand enough about what's going on to file it myself, just that I got caught again this morning with the "Extra usage is required for long context requests" warning and asked omp/Claude to diagnose and fix it.
Environment
Reproduction
The
cozempic init-generatedSessionStarthook runs:This fails every time. Log output:
Contrast: working invocation
Running without
--sessionfrom the same directory succeeds — the daemon auto-detects the correct session ID and starts the 4-tier guard:Impact
The
SessionStarthook is the entire auto-protection mechanism. When--sessionbreaks the daemon, every session silently goes unguarded. In our case: 66 consecutive guard processes spawned across multiple days, all dead on arrival, all leaving stale PID files in/tmp.Workaround
Remove the explicit
--sessioninjection from the hook — replace:cozempic guard --daemon ${SESSION_ID:+--session $SESSION_ID}with:
Guard auto-detects the session correctly when left to its own devices.
Suggested fix
Either:
guard --session <uuid>to resolve the session file path the same way auto-detection does, orcozempic initnot inject--sessioninto the hook (auto-detection already works)