Skip to content

Disable hooks for nested Codex helpers#194

Merged
Lyken17 merged 4 commits into
PolyArch:devfrom
BBuf:codex/disable-nested-codex-hooks
Jun 4, 2026
Merged

Disable hooks for nested Codex helpers#194
Lyken17 merged 4 commits into
PolyArch:devfrom
BBuf:codex/disable-nested-codex-hooks

Conversation

@BBuf
Copy link
Copy Markdown

@BBuf BBuf commented May 31, 2026

Summary

  • probe supported Codex hook feature names before disabling nested Humanize-launched Codex helpers
  • apply the same protection to RLCR stop-hook codex exec / codex review, /humanize:ask-codex, and BitLesson selection
  • keep the dev branch compatibility fixes while preserving hook recursion protection
  • extend tests so nested Codex argv is checked for modern and legacy hook feature names
  • sync the PR branch with dev and keep plugin version metadata at 1.17.0

Root Cause

Humanize already tried to prevent Stop-hook recursion by launching nested Codex with --disable codex_hooks. That covered older Codex builds where the native hook feature was named codex_hooks.

Recent Codex builds expose hook features under stable names such as hooks and plugin_hooks. In those builds, disabling only codex_hooks may not disable the active native/plugin hook paths. When Humanize's Stop hook launches a nested codex exec or codex review, that nested Codex process can load the same Stop hook again, which can re-enter the RLCR loop during review.

At the same time, some older supported Codex builds expose --disable but reject unknown feature names. Passing every known feature unconditionally can make nested codex exec / codex review fail before doing useful work.

Fix

When the installed Codex CLI supports --disable, Humanize now probes each known hook feature name before using it:

hooks
plugin_hooks
codex_hooks

Only supported feature names are passed as repeated --disable <feature> arguments. This keeps compatibility with older codex_hooks builds while also disabling the currently active hook feature names in newer Codex builds.

The same protection is applied to ask-codex.sh and bitlesson-select.sh, since both are nested helper-style Codex invocations and can otherwise inherit the caller's hook environment.

Validation

  • bash -n hooks/loop-codex-stop-hook.sh scripts/bitlesson-select.sh scripts/ask-codex.sh tests/test-disable-nested-codex-hooks.sh tests/test-bitlesson-select-routing.sh tests/test-ask-codex.sh
  • bash tests/test-disable-nested-codex-hooks.sh
  • bash tests/test-bitlesson-select-routing.sh
  • bash tests/test-ask-codex.sh
  • git diff --check

@BBuf BBuf marked this pull request as ready for review May 31, 2026 13:13
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c15eb64d35

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hooks/loop-codex-stop-hook.sh Outdated
Comment on lines +1177 to +1179
[[ "$(cat "$_CODEX_FEATURE_CACHE")" == "yes" ]] && CODEX_DISABLE_HOOKS_ARGS=(--disable hooks --disable plugin_hooks --disable codex_hooks)
elif codex --help 2>&1 | grep -q -- '--disable'; then
CODEX_DISABLE_HOOKS_ARGS=(--disable codex_hooks)
CODEX_DISABLE_HOOKS_ARGS=(--disable hooks --disable plugin_hooks --disable codex_hooks)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Probe feature names before disabling them

When the installed Codex is an older supported build that has --disable but only knows the codex_hooks feature, this unconditional list makes every nested codex exec/codex review fail before it can do any work. Codex v0.114 already exposes --disable and validates each feature name, but its registry key is codex_hooks and does not include hooks or plugin_hooks, so the new probe passes and the subsequent invocation errors with an unknown feature. Please probe codex features list/feature support or fall back per feature instead of treating --disable support as support for all names; the same copied pattern in ask-codex.sh and bitlesson-select.sh needs the same guard.

Useful? React with 👍 / 👎.

@Lyken17
Copy link
Copy Markdown
Contributor

Lyken17 commented Jun 4, 2026

@BBuf

can you

  1. change the base branch of this PR to 'dev'.
  2. update the version numbers so it can be bumped?

@BBuf BBuf changed the base branch from main to dev June 4, 2026 16:17
@Lyken17 Lyken17 merged commit e045999 into PolyArch:dev Jun 4, 2026
5 checks passed
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.

3 participants