openclaw - ✅(Solved) Fix Native hook relay remains unavailable after gateway restart and hooks report 5/5 ready [1 pull requests, 3 comments, 2 participants]

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…
GitHub stats
openclaw/openclaw#73723Fetched 2026-04-29 06:15:56
View on GitHub
Comments
3
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
commented ×3cross-referenced ×1

On OpenClaw 2026.4.26, Codex-native tool execution can get stuck behind the native hook relay even when:

  • commands.native = true
  • commands.nativeSkills = true
  • all internal hooks are enabled
  • the gateway has been restarted
  • the hook loader reports loaded 5 internal hook handlers
  • openclaw hooks list reports Hooks (5/5 ready)

Despite that, Codex-native shell execution is blocked with:

Command blocked by PreToolUse hook: Native hook relay unavailable

The gateway log shows repeated nativeHook.invoke failures:

2026-04-29T01:18:33.503+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:19:30.581+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:19:32.734+08:00 [gateway] signal SIGUSR1 received
2026-04-29T01:19:40.744+08:00 [hooks] loaded 5 internal hook handlers
2026-04-29T01:24:25.742+08:00 [ws] ⇄ res ✗ nativeHook.invoke 1ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:47:40.568+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:50:20.500+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found

This makes the ordinary hook health signal look green while the Codex native hook relay path is still broken.

Error Message

I searched for the exact error string native hook relay not found / Native hook relay unavailable and did not find an existing matching issue.

Root Cause

  • Codex-native shell/tool execution becomes unavailable in the active session.
  • Gateway restart may temporarily improve some surfaces, but it does not reliably repair the active relay path.
  • openclaw hooks list / internal hook readiness can be misleading because 5/5 ready does not imply the native relay for the active Codex session is registered.

Fix Action

Fix / Workaround

Workarounds tried

PR fix notes

PR #73950: fix(codex): share native hook relay registry

Description (problem / solution / changelog)

Summary

Fixes a Codex native hook relay failure where openclaw hooks relay can report native hook relay not found, which Codex surfaces as Native hook relay unavailable and then fail-closes PreToolUse.

The relay registry was held in module-local state. In installations where the Codex extension is loaded through staged plugin runtime deps while the gateway handler uses the host package copy, the same gateway process can have two instances of the relay module. The Codex extension registers the relay id in one module instance, while nativeHook.invoke looks it up in another and cannot find it.

This moves the relay registry and related in-memory state to a globalThis symbol so duplicate module instances inside the same process share the same registry.

Fixes #73723.

Tests

  • corepack pnpm exec oxfmt --check src/agents/harness/native-hook-relay.ts src/agents/harness/native-hook-relay.test.ts
  • corepack pnpm vitest run src/agents/harness/native-hook-relay.test.ts src/cli/native-hook-relay-cli.test.ts src/gateway/server-methods/native-hook-relay.test.ts extensions/codex/src/app-server/native-hook-relay.test.ts extensions/codex/src/app-server/run-attempt.test.ts
  • corepack pnpm tsgo:core:test

Changed files

  • src/agents/harness/native-hook-relay.test.ts (modified, +20/-0)
  • src/agents/harness/native-hook-relay.ts (modified, +28/-7)

Code Example

Command blocked by PreToolUse hook: Native hook relay unavailable

---

2026-04-29T01:18:33.503+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:19:30.581+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:19:32.734+08:00 [gateway] signal SIGUSR1 received
2026-04-29T01:19:40.744+08:00 [hooks] loaded 5 internal hook handlers
2026-04-29T01:24:25.742+08:00 [ws] ⇄ res ✗ nativeHook.invoke 1ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:47:40.568+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:50:20.500+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found

---

{
  "meta": {
    "lastTouchedVersion": "2026.4.25",
    "lastTouchedAt": "2026-04-27T15:59:52.736Z"
  },
  "auth": {
    "profiles": {
      "openai-codex:default": {
        "provider": "openai-codex",
        "mode": "oauth"
      }
    },
    "order": {
      "openai-codex": [
        "openai-codex:default"
      ]
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "codex/gpt-5.5"
      },
      "agentRuntime": {
        "id": "auto",
        "fallback": "pi"
      },
      "workspace": "<redacted-workspace-path>"
    },
    "list": [
      {
        "id": "main"
      }
    ]
  },
  "commands": {
    "native": true,
    "nativeSkills": true,
    "config": true,
    "allowFrom": {
      "telegram": ["<redacted-user-id>"]
    },
    "restart": true,
    "ownerDisplay": "raw"
  },
  "hooks": {
    "internal": {
      "enabled": true,
      "entries": {
        "session-memory": { "enabled": true },
        "command-logger": { "enabled": true },
        "boot-md": { "enabled": true },
        "bootstrap-extra-files": { "enabled": true },
        "self-improvement": { "enabled": true }
      }
    }
  },
  "plugins": {
    "entries": {
      "openai": {
        "enabled": true
      },
      "codex": {
        "enabled": true,
        "config": {
          "appServer": {
            "sandbox": "danger-full-access",
            "transport": "stdio",
            "command": "codex",
            "requestTimeoutMs": 60000,
            "approvalPolicy": "never",
            "approvalsReviewer": "user"
          }
        }
      }
    }
  }
}

---

nativeHook.invoke ... errorCode=INVALID_REQUEST errorMessage=native hook relay not found

---

Command blocked by PreToolUse hook: Native hook relay unavailable
RAW_BUFFERClick to expand / collapse

Summary

On OpenClaw 2026.4.26, Codex-native tool execution can get stuck behind the native hook relay even when:

  • commands.native = true
  • commands.nativeSkills = true
  • all internal hooks are enabled
  • the gateway has been restarted
  • the hook loader reports loaded 5 internal hook handlers
  • openclaw hooks list reports Hooks (5/5 ready)

Despite that, Codex-native shell execution is blocked with:

Command blocked by PreToolUse hook: Native hook relay unavailable

The gateway log shows repeated nativeHook.invoke failures:

2026-04-29T01:18:33.503+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:19:30.581+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:19:32.734+08:00 [gateway] signal SIGUSR1 received
2026-04-29T01:19:40.744+08:00 [hooks] loaded 5 internal hook handlers
2026-04-29T01:24:25.742+08:00 [ws] ⇄ res ✗ nativeHook.invoke 1ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:47:40.568+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found
2026-04-29T01:50:20.500+08:00 [ws] ⇄ res ✗ nativeHook.invoke 0ms errorCode=INVALID_REQUEST errorMessage=native hook relay not found

This makes the ordinary hook health signal look green while the Codex native hook relay path is still broken.

Environment

  • OpenClaw version: 2026.4.26
  • OS: macOS / Darwin 25.3.0, arm64
  • Channel: Telegram direct session
  • Agent model route: codex/gpt-5.5
  • Authentication / harness shape:
    • OpenAI Codex auth is configured through openai-codex OAuth (auth.profiles.openai-codex:default.mode = "oauth")
    • The active agent route uses the bundled codex/gpt-5.5 provider with the Codex app-server harness enabled (plugins.entries.codex.enabled = true)
    • Codex app-server command is codex, transport is stdio, sandbox is danger-full-access, approval policy is never
  • Config facts:
    • commands.native = true
    • commands.nativeSkills = true
    • hooks.internal.enabled = true
    • internal hooks enabled: boot-md, bootstrap-extra-files, command-logger, session-memory, self-improvement

Sanitized relevant config excerpt

Sensitive fields and unrelated providers omitted/redacted:

{
  "meta": {
    "lastTouchedVersion": "2026.4.25",
    "lastTouchedAt": "2026-04-27T15:59:52.736Z"
  },
  "auth": {
    "profiles": {
      "openai-codex:default": {
        "provider": "openai-codex",
        "mode": "oauth"
      }
    },
    "order": {
      "openai-codex": [
        "openai-codex:default"
      ]
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "codex/gpt-5.5"
      },
      "agentRuntime": {
        "id": "auto",
        "fallback": "pi"
      },
      "workspace": "<redacted-workspace-path>"
    },
    "list": [
      {
        "id": "main"
      }
    ]
  },
  "commands": {
    "native": true,
    "nativeSkills": true,
    "config": true,
    "allowFrom": {
      "telegram": ["<redacted-user-id>"]
    },
    "restart": true,
    "ownerDisplay": "raw"
  },
  "hooks": {
    "internal": {
      "enabled": true,
      "entries": {
        "session-memory": { "enabled": true },
        "command-logger": { "enabled": true },
        "boot-md": { "enabled": true },
        "bootstrap-extra-files": { "enabled": true },
        "self-improvement": { "enabled": true }
      }
    }
  },
  "plugins": {
    "entries": {
      "openai": {
        "enabled": true
      },
      "codex": {
        "enabled": true,
        "config": {
          "appServer": {
            "sandbox": "danger-full-access",
            "transport": "stdio",
            "command": "codex",
            "requestTimeoutMs": 60000,
            "approvalPolicy": "never",
            "approvalsReviewer": "user"
          }
        }
      }
    }
  }
}

Relevant upstream context

This looks related to the recently merged native hook relay work:

  • PR #71008: "Bridge Codex native hooks into OpenClaw"
  • PR #71765: "feat(plugins): add before agent finalize hook"

I searched for the exact error string native hook relay not found / Native hook relay unavailable and did not find an existing matching issue.

Steps to reproduce

The exact trigger is not fully isolated yet, but the failure has reproduced repeatedly in a long-running Telegram main session using the Codex harness:

  1. Use OpenClaw 2026.4.26 with Codex native hooks enabled.
  2. Keep commands.native=true and commands.nativeSkills=true.
  3. Use a Codex-backed main session where shell/native tools are expected to route through the native hook relay.
  4. Attempt a shell command from the agent.
  5. Observe the command being blocked by PreToolUse with Native hook relay unavailable.
  6. Restart the gateway.
  7. Confirm the gateway reloads hooks successfully, for example loaded 5 internal hook handlers and Hooks (5/5 ready).
  8. Attempt shell/native tool execution again.
  9. Observe nativeHook.invoke ... errorMessage=native hook relay not found continuing after the successful hook load.

Expected behavior

If the gateway has restarted successfully and the hook loader reports all internal hook handlers ready, Codex-native hook relay registration should also be healthy, or OpenClaw should expose a separate health/status signal showing that the relay for the active Codex session is missing.

Shell/native tool execution should not remain blocked by a stale or missing relay after a successful gateway restart and hook reload.

Actual behavior

The ordinary hook system reports healthy, but native hook relay invocations continue failing:

nativeHook.invoke ... errorCode=INVALID_REQUEST errorMessage=native hook relay not found

The active agent sees:

Command blocked by PreToolUse hook: Native hook relay unavailable

This blocks shell execution and forces fallback paths that do not depend on the native hook relay.

Impact

  • Codex-native shell/tool execution becomes unavailable in the active session.
  • Gateway restart may temporarily improve some surfaces, but it does not reliably repair the active relay path.
  • openclaw hooks list / internal hook readiness can be misleading because 5/5 ready does not imply the native relay for the active Codex session is registered.

Workarounds tried

  • Enabled command-logger so all 5 bundled internal hooks are enabled.
  • Restarted gateway via SIGUSR1.
  • Verified the gateway log reported loaded 5 internal hook handlers.
  • Continued to see nativeHook.invoke ... native hook relay not found after restart.
  • Used non-shell fallback paths where possible.

Suggested diagnosis / possible fix area

The issue appears to be separate from ordinary hook handler loading. It looks more like the per-session/per-run native hook relay registration is stale, missing, expired, or not rebound correctly after gateway restart / thread resume / session recovery.

It would help if OpenClaw exposed or repaired this explicitly, for example:

  • include active native hook relay registrations in diagnostics / hooks list / doctor output;
  • on Codex thread resume, verify that the expected relay exists before enabling Codex native hook config;
  • if the relay is missing, re-register it or fail open/defer to Codex's normal permission path instead of blocking every native tool call;
  • distinguish "hook handlers loaded" from "active Codex native relay registered" in health output.

extent analysis

TL;DR

The issue can be resolved by modifying the OpenClaw configuration to properly handle native hook relay registration after a gateway restart.

Guidance

  1. Verify native hook relay registration: Check the OpenClaw documentation to see if there are any specific settings or commands to verify the native hook relay registration after a gateway restart.
  2. Check Codex thread resume: Investigate how the Codex thread resume handles native hook relay registration and if it needs to be explicitly re-registered after a restart.
  3. Modify health output: Suggest modifying the OpenClaw health output to distinguish between "hook handlers loaded" and "active Codex native relay registered" to provide a clearer picture of the system's status.
  4. Implement retry mechanism: Consider implementing a retry mechanism for native hook relay registration after a gateway restart to ensure that the relay is properly registered before enabling Codex native hook config.

Example

No code snippet is provided as the issue requires configuration changes and modifications to the OpenClaw system rather than a specific code fix.

Notes

The issue appears to be related to the native hook relay registration and its interaction with the Codex thread resume and gateway restart. Further investigation into the OpenClaw configuration and Codex thread resume handling is necessary to provide a complete solution.

Recommendation

Apply a workaround by modifying the OpenClaw configuration to handle native hook relay registration after a gateway restart, as the root cause of the issue is likely related to the registration process.

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…

FAQ

Expected behavior

If the gateway has restarted successfully and the hook loader reports all internal hook handlers ready, Codex-native hook relay registration should also be healthy, or OpenClaw should expose a separate health/status signal showing that the relay for the active Codex session is missing.

Shell/native tool execution should not remain blocked by a stale or missing relay after a successful gateway restart and hook reload.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING