Skip to content

fix(codex): avoid raw hints for non-authoritative rewrites - #214

Open
hxy91819 wants to merge 2 commits into
vincentkoc:mainfrom
hxy91819:fix/codex-compaction-raw-hint
Open

fix(codex): avoid raw hints for non-authoritative rewrites#214
hxy91819 wants to merge 2 commits into
vincentkoc:mainfrom
hxy91819:fix/codex-compaction-raw-hint

Conversation

@hxy91819

@hxy91819 hxy91819 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Codex PostToolUse previously added a tokenjuice wrap --raw recovery hint to every replacement, including normalized/status/formatting-only rewrites where no authoritative content omission was reported. This trained the agent to discard usable context and rerun commands unnecessarily.

This PR now closes both paths that caused unnecessary raw retrieval:

  • carry compaction metadata into the Codex feedback path and emit the raw recovery hint only when compaction.authoritative === true
  • snapshot an active no-omit policy into the installed hook command as codex-post-tool-use --no-omit

The second change is necessary because Codex launches hooks from its own process, which may not inherit TOKENJUICE_NO_OMISSION=1 loaded by the Bash tool's login shell. doctor codex detects an installed hook that no longer matches the requested no-omit policy and recommends reinstalling it.

authoritative: false means no authoritative omission was reported; it does not claim byte-for-byte or formatting preservation. Other host adapters and public reduction APIs are unchanged.

Reproduction

In the affected environment:

  • the Bash tool process contained TOKENJUICE_NO_OMISSION=1
  • the Codex parent process did not
  • a 111-line document was reduced to a 33-line summary and advertised tokenjuice wrap --raw

With the updated installed command, the same hook input keeps the original result, records noOmit: true and compaction.authoritative: false, and emits no raw hint even when the hook process environment does not contain the variable.

Existing Codex hooks must be reinstalled after changing the no-omit policy:

tokenjuice install codex --no-omit
tokenjuice doctor codex --no-omit

Tests

  • env -u TOKENJUICE_NO_OMISSION pnpm verify
    • 131 test files passed
    • 2291 tests passed
  • env -u TOKENJUICE_NO_OMISSION pnpm e2e:local
  • env -u TOKENJUICE_NO_OMISSION pnpm exec vitest run test/hosts/codex.test.ts test/cli/main.test.ts
  • isolated hook probe with the parent environment unset
  • autoreview of df734a6: clean, no accepted/actionable findings

The focused coverage verifies non-authoritative rewrites, authoritative omissions, install-time no-omit capture, stale-hook diagnosis, CLI propagation, and explicit no-omit runtime passthrough.

Compatibility

Existing hooks without --no-omit keep their previous default behavior. Users who enable or disable no-omit should rerun tokenjuice install codex; doctor codex reports the mismatch until they do.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants