openclaw - 💡(How to fix) Fix [Bug]: Codex PreToolUse hook fails with 'Native hook relay unavailable' intermittently

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

The Codex agent harness experiences intermittent failures where the PreToolUse hook blocks all tool execution with the error: This error appears after initial successful command execution — the first few commands (pwd, supabase link, npm run build, etc.) work fine, but after a few turns the PreToolUse hook starts failing consistently until a gateway restart.

Error Trace

Note: The node bridge error is secondary — it's blocked because gateway.nodes.allowCommands only contains file transfer commands. The primary blocker is the PreToolUse hook blocking local shell execution.

Root Cause

Note: The node bridge error is secondary — it's blocked because gateway.nodes.allowCommands only contains file transfer commands. The primary blocker is the PreToolUse hook blocking local shell execution.

Fix Action

Fix / Workaround

  • Codex agent cannot execute commands reliably after initial success
  • Blocks: git push, npm builds, deployments, database operations, etc.
  • Workaround requires gateway restart (destroys current session context)

Code Example

Command blocked by PreToolUse hook: Native hook relay unavailable.

---

Local shell: Command blocked by PreToolUse hook: Native hook relay unavailable.
OpenClaw node: agent=codex node=<NODE_ID> gateway=default action=invoke: node command not allowed: "pwd" is not in the allowlist for platform "macos"
RAW_BUFFERClick to expand / collapse

Bug: Codex PreToolUse hook fails with "Native hook relay unavailable" intermittently

GitHub Issue

Issue Description

The Codex agent harness experiences intermittent failures where the PreToolUse hook blocks all tool execution with the error:

Command blocked by PreToolUse hook: Native hook relay unavailable.

This error appears after initial successful command execution — the first few commands (pwd, supabase link, npm run build, etc.) work fine, but after a few turns the PreToolUse hook starts failing consistently until a gateway restart.

Steps to Reproduce

  1. Start a Codex agent session in Discord
  2. Run several commands successfully (pwd, git status, npm commands, etc.)
  3. After several tool calls (5-20), subsequent commands fail with "Native hook relay unavailable"
  4. Restarting the gateway temporarily fixes it, but the issue recurs

Actual Behavior

  • Local shell commands work initially
  • After an arbitrary number of commands, PreToolUse hook starts blocking with "Native hook relay unavailable"
  • Node bridge is not a viable fallback (empty allowlist — intentional by design)
  • Restarting the gateway restores functionality temporarily

Expected Behavior

  • PreToolUse hook should reliably reach the native hook relay bridge
  • OR: The hook should gracefully degrade when the bridge is unavailable (allow commands to proceed)

Environment

  • Gateway: local mode, loopback bind
  • Channels: Discord (where Codex is bound)
  • Node: macOS node connected but with empty command allowlist (by design for security)
  • Codex: Using OpenAI Codex via openai-codex:[email protected] OAuth profile
  • Agent config: Codex agent bound to channel 1488555354374799521 in Discord guild 1467720910654935134

Error Trace

Local shell: Command blocked by PreToolUse hook: Native hook relay unavailable.
OpenClaw node: agent=codex node=<NODE_ID> gateway=default action=invoke: node command not allowed: "pwd" is not in the allowlist for platform "macos"

Note: The node bridge error is secondary — it's blocked because gateway.nodes.allowCommands only contains file transfer commands. The primary blocker is the PreToolUse hook blocking local shell execution.

Root Cause Hypothesis

The Codex harness injects a PreToolUse hook into all tool calls to give OpenClaw visibility. This hook attempts to reach a "native hook relay" bridge before allowing execution. The bridge registration appears to degrade over time or after a certain number of tool calls, causing the hook to fail.

The native hook relay is an internal Codex/OpenClaw bridge that seems to have a lifecycle bug where it stops responding after extended use within a session.

Impact

  • Codex agent cannot execute commands reliably after initial success
  • Blocks: git push, npm builds, deployments, database operations, etc.
  • Workaround requires gateway restart (destroys current session context)

Tags

  • impact:codex
  • impact:tool-execution
  • P1 (blocks production use of Codex agent)

Reported from user session via OpenClaw Discord #command-center

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING