Summary
Removed direct dependencies on pydantic-ai from the src/tunacode/tools/ directory (specifically ModelRetry). Tools now raise a domain-specific ToolRetryError, which is intercepted by the tool decorator and translated to ModelRetry for the framework.
Context
Previously, 8 tool files imported ModelRetry from pydantic_ai.exceptions. This coupled the business logic of the tools directly to the specific agent framework we are using.
Changes
- Added
ToolRetryErrortosrc/tunacode/exceptions.py. - Updated
src/tunacode/tools/decorators.pyto catchToolRetryErrorand raiseModelRetry. This file now acts as the Adapter. - Updated 7 tools to import and raise
ToolRetryErrorinstead ofModelRetry:bash.pyglob.pygrep.pylist_dir.pyupdate_file.pyweb_fetch.pywrite_file.py
Behavioral Impact
No external behavioral change. The LLM still receives the retry signal exactly as before. The change is purely internal structural improvement.