Summary
Codex reports the autodev PreCompact hook as failed because the hook output is not valid PreCompact hook JSON.
Observed UI message:
PreCompact hook (failed)
error: hook returned invalid PreCompact hook JSON output
Impact
The failure interrupts or degrades compaction-time state handling, and it makes it hard to tell whether autodev actually recorded the intended checkpoint state before context compaction.
Expected behavior
The PreCompact hook should always emit valid hook JSON on stdout. Any diagnostics, locale warnings, shell tracing, or helper output should be sent to stderr or suppressed before JSON is printed.
Notes
We have seen related hook-output fragility around shell environment/locale behavior. The fix likely belongs in the hook wrapper layer so every hook runs with deterministic locale/env setup and strict stdout discipline, rather than relying on each hook script to remember it.
Suggested acceptance criteria:
- Reproduce PreCompact execution in a minimal Codex/autodev install.
- Add wrapper-level detection that validates stdout is JSON before returning it to Codex.
- Ensure wrapper exports a deterministic locale such as
LC_ALL=C.UTF-8/LANG=C.UTF-8 where available, with a portable fallback.
- Route non-JSON diagnostic output to stderr.
- Add a regression test covering noisy helper output and locale warning output.
Summary
Codex reports the autodev PreCompact hook as failed because the hook output is not valid PreCompact hook JSON.
Observed UI message:
Impact
The failure interrupts or degrades compaction-time state handling, and it makes it hard to tell whether autodev actually recorded the intended checkpoint state before context compaction.
Expected behavior
The PreCompact hook should always emit valid hook JSON on stdout. Any diagnostics, locale warnings, shell tracing, or helper output should be sent to stderr or suppressed before JSON is printed.
Notes
We have seen related hook-output fragility around shell environment/locale behavior. The fix likely belongs in the hook wrapper layer so every hook runs with deterministic locale/env setup and strict stdout discipline, rather than relying on each hook script to remember it.
Suggested acceptance criteria:
LC_ALL=C.UTF-8/LANG=C.UTF-8where available, with a portable fallback.