fix: expand tilde (~) in vision_analyze local file paths (#2585)

Path('~/.hermes/image.png').is_file() returns False because Path
doesn't expand tilde. This caused the tool to fall through to URL
validation, which also failed, producing a confusing error:
'Invalid image source. Provide an HTTP/HTTPS URL or a valid local
file path.'

Fix: use os.path.expanduser() before constructing the Path object.
Added two tests for tilde expansion (success and nonexistent file).
This commit is contained in:
Teknium
2026-03-22 23:48:32 -07:00
committed by GitHub
parent 3b509da571
commit b072737193
2 changed files with 57 additions and 1 deletions

View File

@@ -242,7 +242,7 @@ async def vision_analyze_tool(
logger.info("User prompt: %s", user_prompt[:100])
# Determine if this is a local file path or a remote URL
local_path = Path(image_url)
local_path = Path(os.path.expanduser(image_url))
if local_path.is_file():
# Local file path (e.g. from platform image cache) -- skip download
logger.info("Using local image file: %s", image_url)