fix(filesystem): clarify optional tool argument handling

Keep the mypy-friendly optional execute signatures while returning clearer errors for missing arguments and locking that behavior with regression tests.

Made-with: Cursor
This commit is contained in:
Xubin Ren
2026-03-24 11:49:10 +08:00
committed by Xubin Ren
parent d4a7194c88
commit d25985be0b
2 changed files with 19 additions and 2 deletions
+2 -2
View File
@@ -96,7 +96,7 @@ class ReadFileTool(_FsTool):
async def execute(self, path: str | None = None, offset: int = 1, limit: int | None = None, **kwargs: Any) -> Any:
try:
if not path:
return f"Error: File not found: {path}"
return "Error reading file: Unknown path"
fp = self._resolve(path)
if not fp.exists():
return f"Error: File not found: {path}"
@@ -264,7 +264,7 @@ class EditFileTool(_FsTool):
if old_text is None:
raise ValueError("Unknown old_text")
if new_text is None:
raise ValueError("Unknown next_text")
raise ValueError("Unknown new_text")
fp = self._resolve(path)
if not fp.exists():