# Root Cause

> listdir raised FileNotFoundError on non-existent directories, which @basetool wrapped as ToolExecutionError.

- Skill: `tools-only/root-cause-6` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/root-cause-6`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/root-cause-6/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/root-cause-6

---


## Summary

`list_dir` raised `FileNotFoundError` on non-existent directories, which `@base_tool` wrapped as `ToolExecutionError`. Since `ToolExecutionError` is in `NON_RETRYABLE_ERRORS`, the agent halted instead of letting the LLM self-correct with a valid path.

## Context

Surfaced when agent called `list_dir("/home/tuna/tunacode/apps")` - a directory that doesn't exist. Agent crashed with `ToolExecutionError` instead of retrying.

## Root Cause

Error propagation chain:
1. `list_dir` raises `FileNotFoundError`
2. `@base_tool` decorator wraps it as `ToolExecutionError`
3. `tool_executor.py` has `ToolExecutionError` in `NON_RETRYABLE_ERRORS`
4. Non-retryable errors propagate immediately, halting the agent

First attempted fix: switch to `@file_tool` decorator. Failed because `@file_tool` expects required `filepath` positional arg, but `list_dir` has optional `directory="."`.

## Changes

- Import `ModelRetry` from `pydantic_ai.exceptions`
- Replace `raise FileNotFoundError(...)` with `raise ModelRetry(...)`
- Replace `raise NotADirectoryError(...)` with `raise ModelRetry(...)`
- Keep `@base_tool` decorator (not `@file_tool`)

## Behavioral Impact

- Agent no longer halts on bad directory paths
- LLM receives retry signal with error message, can self-correct
- No change to valid path behavior

## Related Cards

- [[glob-grep-error-strings]] - similar smell: return error strings instead of raising

