# Normalize Tool Names Before Dispatch

> Tool calls with leading/trailing whitespace in tool_name failed to dispatch (e.g., " glob"), resulting in unknown-tool errors instead of retries.

- Skill: `tools-only/normalize-tool-names-before-dispatch` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/normalize-tool-names-before-dispatch`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/normalize-tool-names-before-dispatch/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-29
- Page: https://skillmd.com/skills/tools-only/normalize-tool-names-before-dispatch

---


# Normalize Tool Names Before Dispatch

## Summary

Tool calls with leading/trailing whitespace in `tool_name` failed to dispatch (e.g., " glob"), resulting in unknown-tool errors instead of retries. We now normalize tool names before registration and dispatch to avoid whitespace-induced failures.

## Context

- File: `src/tunacode/core/agents/agent_components/orchestrator/tool_dispatcher.py`
- Symptom: tool names like " glob" were treated as unknown tools.
- Gap: tests covered suspicious characters but not whitespace-only tool names.

## Root Cause

Tool names were used verbatim from model output, and the suspicious-name guard did not treat whitespace as invalid. This allowed malformed names to reach dispatch without correction.

## Changes

- Added `_normalize_tool_name()` to trim whitespace and fall back to `UNKNOWN_TOOL_NAME` for empty results.
- Normalized tool names during structured and fallback tool-call registration.
- Updated tool-call parts in place only when normalization changes the name.

## Behavioral Impact

- Tool calls with incidental whitespace now dispatch correctly.
- Empty/whitespace-only tool names fail fast as `unknown` and trigger model retry prompts.
- No change to tool execution retry/backoff behavior.

## Related Cards

- [[tool-dispatcher]]
- [[tool-calls]]

