Skip to content

[Bug]: Tool Names Not Trimmed, Causing "Tool Not Found" Errors #27045

@Lo10Th

Description

@Lo10Th

Summary

OpenClaw fails to execute tools when the model outputs tool names with leading/trailing whitespace. The error message shows "Tool not found" (notice double space), indicating the tool name is empty or contains whitespace that isn't being trimmed before lookup.

Steps to reproduce

  1. Start any OpenClaw session
  2. Ask the agent to perform tool calls (read, exec, gateway, etc.)
  3. Observe intermittent failures with error: {"status": "error", "tool": "<tool_name>", "error": "Tool not found"}

Note the double space in "Tool not found" - the tool name is empty or whitespace-padded.

Expected behavior

Tool names should be normalized (trimmed of leading/trailing whitespace) before lookup. The following should all work:

• Tool call with "read" → executes read tool
• Tool call with " read" → executes read tool (whitespace trimmed)
• Tool call with "read " → executes read tool (whitespace trimmed)
• Tool call with " read " → executes read tool (whitespace trimmed)

The system should gracefully handle whitespace in tool names and match them correctly to available tools.

Actual behavior

Tool calls fail intermittently when the model outputs tool names with whitespace:

Input: {"file_path": "/data/.openclaw/workspace/test.txt"}
Error: {"status": "error", "tool": "read", "error": "Tool not found"}

The double space in "Tool not found" indicates call.name is empty or contains only whitespace. The lookup fails because " read" ≠ "read" in the toolsByName map.

OpenClaw version

2026.2.23

Operating system

Linux 6.8.0-94-generic (x64)

Install method

docker

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions