openclaw - 💡(How to fix) Fix [Bug]: @openclaw/codex fails before reply when local npm tree loses openclaw peer link [1 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#78185Fetched 2026-05-06 06:16:12
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Author
Timeline (top)
closed ×1commented ×1

On OpenClaw 2026.5.4, Discord can receive a mention, create the reply thread, and show typing, but never send a response. The gateway error is a Codex harness import failure before any assistant reply:

Embedded agent failed before reply: Cannot find package 'openclaw' imported from /Users/local/.openclaw/npm/node_modules/@openclaw/codex/dist/shared-client-B7LbV3PF.js

Restoring the host OpenClaw peer link in the local external-plugin npm tree fixes the issue immediately:

ln -s /Users/local/.npm-global/lib/node_modules/openclaw /Users/local/.openclaw/npm/node_modules/openclaw
openclaw gateway restart

After that, importing the shared-client bundle succeeds and openclaw agent ... returns normally.

Error Message

On OpenClaw 2026.5.4, Discord can receive a mention, create the reply thread, and show typing, but never send a response. The gateway error is a Codex harness import failure before any assistant reply: node -e "const { readdirSync } = require('node:fs'); const { join } = require('node:path'); const dir=process.env.HOME + '/.openclaw/npm/node_modules/@openclaw/codex/dist'; const file=readdirSync(dir).find((name)=>/^shared-client-.*\.js$/.test(name)); console.log({file}); import(join(dir,file)).catch(e=>{console.error(e); process.exit(1)})"

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'openclaw' imported from .../shared-client-*.js

  1. If a Discord turn has already become user-visible, harness startup failure should produce a visible error reply instead of silent typing/no response.
  • No error is sent to the Discord user. node -e "const { readdirSync } = require('node:fs'); const { join } = require('node:path'); const dir='/Users/local/.openclaw/npm/node_modules/@openclaw/codex/dist'; const file=readdirSync(dir).find((name)=>/^shared-client-.*\.js$/.test(name)); if(!file) throw new Error('shared-client bundle not found'); import(join(dir,file)).then(()=>console.log('codex shared-client import ok')).catch(e=>{console.error(e.message); process.exit(1)})"

Root Cause

On OpenClaw 2026.5.4, Discord can receive a mention, create the reply thread, and show typing, but never send a response. The gateway error is a Codex harness import failure before any assistant reply:

Embedded agent failed before reply: Cannot find package 'openclaw' imported from /Users/local/.openclaw/npm/node_modules/@openclaw/codex/dist/shared-client-B7LbV3PF.js

Restoring the host OpenClaw peer link in the local external-plugin npm tree fixes the issue immediately:

ln -s /Users/local/.npm-global/lib/node_modules/openclaw /Users/local/.openclaw/npm/node_modules/openclaw
openclaw gateway restart

After that, importing the shared-client bundle succeeds and openclaw agent ... returns normally.

Fix Action

Workaround

ln -s /Users/local/.npm-global/lib/node_modules/openclaw /Users/local/.openclaw/npm/node_modules/openclaw
node -e "const { readdirSync } = require('node:fs'); const { join } = require('node:path'); const dir='/Users/local/.openclaw/npm/node_modules/@openclaw/codex/dist'; const file=readdirSync(dir).find((name)=>/^shared-client-.*\\.js$/.test(name)); if(!file) throw new Error('shared-client bundle not found'); import(join(dir,file)).then(()=>console.log('codex shared-client import ok')).catch(e=>{console.error(e.message); process.exit(1)})"
openclaw gateway restart
openclaw channels status --probe

After this, a direct diagnostic turn returned OK with agentHarnessId: "codex".

Code Example

Embedded agent failed before reply: Cannot find package 'openclaw' imported from /Users/local/.openclaw/npm/node_modules/@openclaw/codex/dist/shared-client-B7LbV3PF.js

---

ln -s /Users/local/.npm-global/lib/node_modules/openclaw /Users/local/.openclaw/npm/node_modules/openclaw
openclaw gateway restart

---

{
  "peerDependencies": {
    "openclaw": ">=2026.5.4-beta.1"
  },
  "peerDependenciesMeta": {
    "openclaw": {
      "optional": true
    }
  }
}

---

ls -la ~/.openclaw/npm/node_modules/openclaw
# No such file or directory

node -e "const { readdirSync } = require('node:fs'); const { join } = require('node:path'); const dir=process.env.HOME + '/.openclaw/npm/node_modules/@openclaw/codex/dist'; const file=readdirSync(dir).find((name)=>/^shared-client-.*\\.js$/.test(name)); console.log({file}); import(join(dir,file)).catch(e=>{console.error(e); process.exit(1)})"
# Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'openclaw' imported from .../shared-client-*.js

---

ln -s /Users/local/.npm-global/lib/node_modules/openclaw /Users/local/.openclaw/npm/node_modules/openclaw
node -e "const { readdirSync } = require('node:fs'); const { join } = require('node:path'); const dir='/Users/local/.openclaw/npm/node_modules/@openclaw/codex/dist'; const file=readdirSync(dir).find((name)=>/^shared-client-.*\\.js$/.test(name)); if(!file) throw new Error('shared-client bundle not found'); import(join(dir,file)).then(()=>console.log('codex shared-client import ok')).catch(e=>{console.error(e.message); process.exit(1)})"
openclaw gateway restart
openclaw channels status --probe
RAW_BUFFERClick to expand / collapse

Summary

On OpenClaw 2026.5.4, Discord can receive a mention, create the reply thread, and show typing, but never send a response. The gateway error is a Codex harness import failure before any assistant reply:

Embedded agent failed before reply: Cannot find package 'openclaw' imported from /Users/local/.openclaw/npm/node_modules/@openclaw/codex/dist/shared-client-B7LbV3PF.js

Restoring the host OpenClaw peer link in the local external-plugin npm tree fixes the issue immediately:

ln -s /Users/local/.npm-global/lib/node_modules/openclaw /Users/local/.openclaw/npm/node_modules/openclaw
openclaw gateway restart

After that, importing the shared-client bundle succeeds and openclaw agent ... returns normally.

Why this seems upstream-relevant

This is similar to the previously fixed class of plugin peer-link issues, but it appears to still be reproducible through the @openclaw/codex packaged plugin path under ~/.openclaw/npm/node_modules.

Local package metadata shows @openclaw/codex declares openclaw as an optional peer dependency:

{
  "peerDependencies": {
    "openclaw": ">=2026.5.4-beta.1"
  },
  "peerDependenciesMeta": {
    "openclaw": {
      "optional": true
    }
  }
}

However, the generated runtime bundle imports openclaw at startup. That means update/install/repair flows can leave the package manager in a state that looks acceptable, while the Codex harness is guaranteed to fail before reply.

Observed environment

  • OpenClaw: 2026.5.4 (325df3e)
  • @openclaw/codex: 2026.5.4-beta.1
  • OS: macOS arm64
  • Node: 22.17.0
  • Install/update style: global openclaw with local OpenClaw workspace npm tree under ~/.openclaw/npm/node_modules
  • Discord channel status: connected and probe works
  • Failing path: /Users/local/.openclaw/npm/node_modules/@openclaw/codex/dist/shared-client-B7LbV3PF.js
  • Missing path before repair: /Users/local/.openclaw/npm/node_modules/openclaw
  • Existing host package path: /Users/local/.npm-global/lib/node_modules/openclaw

Reproduction shape

I do not yet have the exact update operation that deleted the link, but the broken state is easy to identify:

ls -la ~/.openclaw/npm/node_modules/openclaw
# No such file or directory

node -e "const { readdirSync } = require('node:fs'); const { join } = require('node:path'); const dir=process.env.HOME + '/.openclaw/npm/node_modules/@openclaw/codex/dist'; const file=readdirSync(dir).find((name)=>/^shared-client-.*\\.js$/.test(name)); console.log({file}); import(join(dir,file)).catch(e=>{console.error(e); process.exit(1)})"
# Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'openclaw' imported from .../shared-client-*.js

Then trigger the agent from Discord. Gateway logs show the harness failure and the Discord user sees typing/thread creation but no response.

Expected behavior

One or more of these should happen:

  1. The install/update/repair flow should ensure openclaw is linked into ~/.openclaw/npm/node_modules when @openclaw/codex needs it.
  2. @openclaw/codex should not mark openclaw as optional if the runtime bundle imports it unconditionally.
  3. Gateway startup or plugin repair should detect the missing peer link and repair or report it clearly.
  4. If a Discord turn has already become user-visible, harness startup failure should produce a visible error reply instead of silent typing/no response.

Actual behavior

  • Discord appears healthy and connected.
  • The bot creates a reply thread and shows typing.
  • Codex harness fails before reply with ERR_MODULE_NOT_FOUND.
  • No error is sent to the Discord user.

Workaround

ln -s /Users/local/.npm-global/lib/node_modules/openclaw /Users/local/.openclaw/npm/node_modules/openclaw
node -e "const { readdirSync } = require('node:fs'); const { join } = require('node:path'); const dir='/Users/local/.openclaw/npm/node_modules/@openclaw/codex/dist'; const file=readdirSync(dir).find((name)=>/^shared-client-.*\\.js$/.test(name)); if(!file) throw new Error('shared-client bundle not found'); import(join(dir,file)).then(()=>console.log('codex shared-client import ok')).catch(e=>{console.error(e.message); process.exit(1)})"
openclaw gateway restart
openclaw channels status --probe

After this, a direct diagnostic turn returned OK with agentHarnessId: "codex".

Related

Possibly related to the same broader peer-link failure class:

  • #48552: Docker self-build loses node_modules/openclaw self-reference
  • Release note for v2026.4.23-beta.6: plugin install/startup fixes around openclaw peer dependency and Cannot find package 'openclaw'
  • #48361: interactive channels should not silently swallow user-visible run failures

extent analysis

TL;DR

The issue can be resolved by ensuring the openclaw package is properly linked in the ~/.openclaw/npm/node_modules directory, which can be achieved by running a specific command to create a symbolic link.

Guidance

  • Verify that the openclaw package is installed and available in the ~/.npm-global/lib/node_modules directory.
  • Check if the @openclaw/codex package has a valid peer dependency on openclaw by examining its package.json file.
  • Run the command ln -s /Users/local/.npm-global/lib/node_modules/openclaw /Users/local/.openclaw/npm/node_modules/openclaw to create a symbolic link to the openclaw package.
  • Restart the OpenClaw gateway using the command openclaw gateway restart to apply the changes.

Example

ln -s /Users/local/.npm-global/lib/node_modules/openclaw /Users/local/.openclaw/npm/node_modules/openclaw
openclaw gateway restart

Notes

The issue seems to be related to a peer dependency problem between @openclaw/codex and openclaw. The provided workaround resolves the issue by creating a symbolic link to the openclaw package, but a more permanent solution may involve updating the @openclaw/codex package to properly handle its peer dependency on openclaw.

Recommendation

Apply the workaround by running the command to create a symbolic link to the openclaw package, as this resolves the issue immediately. A more permanent solution may require updates to the @openclaw/codex package.

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

One or more of these should happen:

  1. The install/update/repair flow should ensure openclaw is linked into ~/.openclaw/npm/node_modules when @openclaw/codex needs it.
  2. @openclaw/codex should not mark openclaw as optional if the runtime bundle imports it unconditionally.
  3. Gateway startup or plugin repair should detect the missing peer link and repair or report it clearly.
  4. If a Discord turn has already become user-visible, harness startup failure should produce a visible error reply instead of silent typing/no response.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING