Skip to content
Back to skills

467 List Dir Tool Execution Error D1befeab

ASecurity

`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.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 1, 2026
ai-agents

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned June 1, 2026

npx -y skills add tools-only/X-Skills --skill 467-list-dir-tool-execution-error_d1befeab --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 467 List Dir Tool Execution Error D1befeab?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 467 List Dir Tool Execution Error D1befeab
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-467-list-dir-tool-execution-error-d1befeab/badge)](https://www.skillsdirectory.com/skills/tools-only-467-list-dir-tool-execution-error-d1befeab)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
title: list_dir halts agent on bad paths
link: list-dir-tool-execution-error
type: delta
path: src/tunacode/tools/list_dir.py
depth: 0
seams: [M] module
ontological_relations:
  - relates_to: [[tools]]
  - affects: [[tool-executor]]
  - fixes: [[agent-halt-on-tool-error]]
tags:
  - tools
  - error-handling
  - list_dir
  - ModelRetry
created_at: 2026-01-07T22:54:00-08:00
updated_at: 2026-01-07T23:15:00-08:00
uuid: a1b2c3d4-e5f6-7890-abcd-ef1234567890
---

## 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

Files in this skill

  • README.md1.1 KB
  • skill.md1.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.