openclaw - 💡(How to fix) Fix [Bug]: Codex agent harness crashes with 'hasBeforeToolCallPolicy is not a function' in v2026.5.14-beta.2 [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

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#83984Fetched 2026-05-20 03:45:35
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
1
Author
Timeline (top)
labeled ×3closed ×1commented ×1

When using any GPT model via Codex OAuth (e.g. openai/gpt-5.5, openai/gpt-5.4), every agent turn crashes immediately with:

TypeError: (0 , _agentHarnessRuntime.hasBeforeToolCallPolicy) is not a function
Embedded agent failed before reply
Codex agent harness failed; not falling back to embedded PI backend

The user sees: "⚠️ Something went wrong while processing your request."

Error Message

TypeError: (0 , _agentHarnessRuntime.hasBeforeToolCallPolicy) is not a function Embedded agent failed before reply Codex agent harness failed; not falling back to embedded PI backend

Root Cause

The function hasBeforeToolCallPolicy is imported but not exported from agent-harness-runtime-BT_c8zrV.js. The Codex harness calls it, but the module does not provide it.

Verified by grepping the dist:

$ grep -rn "hasBeforeToolCallPolicy" /path/to/openclaw/dist/
(no matches)

The agent-harness-runtime file exports these functions but NOT hasBeforeToolCallPolicy:

  • queueAgentHarnessMessage
  • inferToolMetaFromArgs
  • formatToolProgressOutput
  • classifyAgentHarnessTerminalOutcome
  • etc.

Fix Action

Workaround

  • Use non-Codex models (DeepSeek native API, etc.)
  • Ensure agents.defaults.model.primary is NOT set to a Codex model (would crash on every gateway restart)

Code Example

TypeError: (0 , _agentHarnessRuntime.hasBeforeToolCallPolicy) is not a function
Embedded agent failed before reply
Codex agent harness failed; not falling back to embedded PI backend

---

$ grep -rn "hasBeforeToolCallPolicy" /path/to/openclaw/dist/
(no matches)
RAW_BUFFERClick to expand / collapse

Summary

When using any GPT model via Codex OAuth (e.g. openai/gpt-5.5, openai/gpt-5.4), every agent turn crashes immediately with:

TypeError: (0 , _agentHarnessRuntime.hasBeforeToolCallPolicy) is not a function
Embedded agent failed before reply
Codex agent harness failed; not falling back to embedded PI backend

The user sees: "⚠️ Something went wrong while processing your request."

Environment

  • OpenClaw: v2026.5.14-beta.2 (e029c12)
  • OS: Ubuntu 24.04 (Linux 6.8.0-101-generic x64)
  • Node: v24.15.0
  • Auth: openai-codex OAuth (ChatGPT Plus subscription)
  • Install: npm global

Steps to Reproduce

  1. Set model to openai/gpt-5.5 or openai/gpt-5.4 via Codex OAuth
  2. Send any message → immediate crash with hasBeforeToolCallPolicy is not a function

Root Cause

The function hasBeforeToolCallPolicy is imported but not exported from agent-harness-runtime-BT_c8zrV.js. The Codex harness calls it, but the module does not provide it.

Verified by grepping the dist:

$ grep -rn "hasBeforeToolCallPolicy" /path/to/openclaw/dist/
(no matches)

The agent-harness-runtime file exports these functions but NOT hasBeforeToolCallPolicy:

  • queueAgentHarnessMessage
  • inferToolMetaFromArgs
  • formatToolProgressOutput
  • classifyAgentHarnessTerminalOutcome
  • etc.

Workaround

  • Use non-Codex models (DeepSeek native API, etc.)
  • Ensure agents.defaults.model.primary is NOT set to a Codex model (would crash on every gateway restart)

Severity

Critical — completely blocks all GPT models via ChatGPT OAuth/Codex subscription path. All models using the Codex agent harness are affected.

Possible Fix

Likely needs the hasBeforeToolCallPolicy function to be added to the agent-harness-runtime module exports. Suspect this was introduced in a recent refactor (v5.14-beta series).

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