openclaw - ✅(Solved) Fix [Bug]: f.toLowerCase is not a function in agent:bootstrap hook (v2026.4.14) [2 pull requests, 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#68124Fetched 2026-04-18 05:53:50
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×2referenced ×2commented ×1

The agent:bootstrap internal hook fires a "f.toLowerCase is not a function" error on every agent start and periodically during runtime. No stack trace is emitted. Error is non-blocking — agents still respond — but floods logs.

Error Message

The agent:bootstrap internal hook fires a "f.toLowerCase is not a function" error on every agent start and periodically during runtime. No stack trace is emitted. Error is non-blocking — agents still respond — but floods logs. 3. Observe logs — error fires on every bootstrap event The agent:bootstrap hook should either succeed silently or, if an error occurs, emit a stack trace identifying the source. Error "f.toLowerCase is not a function" is logged without a stack trace on every agent bootstrap and periodically during runtime. The source cannot be isolated from the log output alone. Agents continue to function despite the error. Error occurs on every agent:bootstrap event: 2026-04-15T10:09:07.076+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function 2026-04-15T10:11:17.758+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function 2026-04-17T09:18:26.331+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function 2026-04-17T09:18:30.816+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function 2026-04-17T12:08:33.168+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function

Root Cause

The agent:bootstrap internal hook fires a "f.toLowerCase is not a function" error on every agent start and periodically during runtime. No stack trace is emitted. Error is non-blocking — agents still respond — but floods logs.

Fix Action

Fixed

PR fix notes

PR #68127: fix: prevent toLowerCase error when model.id or model.name is undefined

Description (problem / solution / changelog)

Summary

Fixes the "f.toLowerCase is not a function" error that occurs in the agent:bootstrap hook when model.id or model.name is undefined.

Root Cause

In canonicalizeLegacyResolvedModel() (src/agents/pi-embedded-runner/model.ts), the code called .trim().toLowerCase() on params.model.id and params.model.name without first checking if they are strings. When these properties are undefined (which can happen with certain model configurations), it causes a TypeError.

Fix

Added typeof checks before calling string methods:

  • Check typeof params.model.id === "string" before calling trim/toLowerCase
  • Check typeof params.model.name === "string" before calling trim/toLowerCase

Test Plan

  • Existing unit tests pass (src/agents/pi-embedded-runner/model.inline-provider.test.ts)
  • Lint checks pass

Closes openclaw#68124

Changed files

  • src/agents/pi-embedded-runner/model.ts (modified, +5/-1)

PR #68300: fix(hooks): include stack trace and event context in internal hook error logs

Description (problem / solution / changelog)

Summary

  • Hook handler errors were logged with only the error message, no stack trace
  • Errors like f.toLowerCase is not a function in agent:bootstrap hooks could not be traced to their source without source maps
  • Now logs the full stack trace and event context (type, action, sessionKey) alongside the error message

Change Type

  • Bug fix

Scope

  • Gateway / orchestration

Linked Issue/PR

  • Closes #68124

Root Cause

triggerInternalHook caught handler errors and logged only err.message. Without the stack trace, operators running 20+ agents with per-agent workspaces had no way to identify which hook or handler was throwing on every bootstrap.

Fix

Extract err.stack from Error instances and pass it as a structured field in the log call alongside the event type, action, and sessionKey. Non-Error throws fall back to undefined for the stack field.

Changed files

  • src/hooks/internal-hooks.ts (modified, +5/-1)

Code Example

Error occurs on every agent:bootstrap event:

2026-04-15T10:09:07.076+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function
2026-04-15T10:11:17.758+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function
2026-04-17T09:18:26.331+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function
2026-04-17T09:18:30.816+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function
2026-04-17T12:08:33.168+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function

Environment verified clean:
- All agent model configs (primary + fallbacks) are strings
- All agents.defaults.models keys are strings
- No non-string values in hooks.internal.entries
- Reproduced on both v2026.4.12 and v2026.4.14

Related: issue #5062 describes the same TypeError pattern in Ollama model discovery code where `modelId = model.name` can be undefined. A similar defensive null coalescing fix may apply here.
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

The agent:bootstrap internal hook fires a "f.toLowerCase is not a function" error on every agent start and periodically during runtime. No stack trace is emitted. Error is non-blocking — agents still respond — but floods logs.

Steps to reproduce

  1. Configure 20 agents with per-agent workspaces and agentDir paths
  2. Start gateway via docker compose up
  3. Observe logs — error fires on every bootstrap event

Expected behavior

The agent:bootstrap hook should either succeed silently or, if an error occurs, emit a stack trace identifying the source.

Actual behavior

Error "f.toLowerCase is not a function" is logged without a stack trace on every agent bootstrap and periodically during runtime. The source cannot be isolated from the log output alone. Agents continue to function despite the error.

OpenClaw version

v2026.4.14

Operating system

Ubuntu 24.04 LTS

Install method

Docker (or npm install if that's the closer option)

Model

Multiple (claude-sonnet-4-6, claude-opus-4-7, deepseek-chat, glm-5.1)

Provider / routing chain

anthropic, deepseek, zai, minimax, openai, modelstudio

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Error occurs on every agent:bootstrap event:

2026-04-15T10:09:07.076+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function
2026-04-15T10:11:17.758+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function
2026-04-17T09:18:26.331+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function
2026-04-17T09:18:30.816+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function
2026-04-17T12:08:33.168+00:00 [internal-hooks] Hook error [agent:bootstrap]: f.toLowerCase is not a function

Environment verified clean:
- All agent model configs (primary + fallbacks) are strings
- All agents.defaults.models keys are strings
- No non-string values in hooks.internal.entries
- Reproduced on both v2026.4.12 and v2026.4.14

Related: issue #5062 describes the same TypeError pattern in Ollama model discovery code where `modelId = model.name` can be undefined. A similar defensive null coalescing fix may apply here.

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

The most likely fix for the "f.toLowerCase is not a function" error on every agent start and periodically during runtime is to apply a defensive null coalescing fix to ensure that the variable being called with toLowerCase() is a string.

Guidance

  • Review the code for the agent:bootstrap internal hook to identify where the f.toLowerCase() call is being made and ensure that f is a string before calling toLowerCase() on it.
  • Verify that all model configurations and hooks are properly set up with string values to prevent undefined or non-string values from being passed to the agent:bootstrap hook.
  • Consider adding a null coalescing fix, similar to the one applied in issue #5062, to handle cases where the variable being called with toLowerCase() might be undefined or null.
  • Check the logs again after applying the fix to confirm that the error is no longer occurring.

Example

// Before
const result = f.toLowerCase();

// After (with null coalescing fix)
const result = (f || '').toLowerCase();

Notes

The exact fix may depend on the specific code implementation of the agent:bootstrap hook, which is not provided in the issue. However, applying a defensive null coalescing fix is a safe and reasonable approach to prevent the "f.toLowerCase is not a function" error.

Recommendation

Apply a workaround by adding a null coalescing fix to ensure that the variable being called with toLowerCase() is a string, as this is a safe and reasonable approach to prevent the error without requiring a version upgrade.

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

The agent:bootstrap hook should either succeed silently or, if an error occurs, emit a stack trace identifying the source.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: f.toLowerCase is not a function in agent:bootstrap hook (v2026.4.14) [2 pull requests, 1 comments, 2 participants]