# Steps (Executed 2026-01-28)

> Remove the direct dependency on pydantic-ai from src/tunacode/tools/. Tools should raise domain-specific exceptions, not framework-specific exceptions.

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

---


## Goal
Remove the direct dependency on `pydantic-ai` from `src/tunacode/tools/`.
Tools should raise domain-specific exceptions, not framework-specific exceptions.

## Strategy
1.  **Define Protocol:** Create `ToolRetryError` in `src/tunacode/exceptions.py`.
2.  **Adapter Layer:** Update `src/tunacode/tools/decorators.py` to catch `ToolRetryError` and re-raise `pydantic_ai.ModelRetry`.
3.  **Refactor Tools:** Update all tools to raise `ToolRetryError` instead of `ModelRetry`.

## Steps (Executed 2026-01-28)

### Step 1: Define Exception
- Added `ToolRetryError` to `src/tunacode/exceptions.py`.

### Step 2: Update Decorator
- Modified `src/tunacode/tools/decorators.py` to catch `ToolRetryError` and re-raise `ModelRetry`.
- This acts as the translation layer between our internal tool protocol and the Pydantic-AI framework.

### Step 3: Migrate Tools
- Replaced `ModelRetry` with `ToolRetryError` in:
    - `tools/bash.py`
    - `tools/glob.py`
    - `tools/grep.py`
    - `tools/list_dir.py`
    - `tools/update_file.py`
    - `tools/web_fetch.py`
    - `tools/write_file.py`

## Verification
`grep -r "pydantic_ai" src/tunacode/tools/` returns only `decorators.py`.
Dependencies are now correctly directed: `tools` -> `exceptions` <- `decorator` -> `pydantic-ai`.

