Skip to content

feat: Add save parameter to image_search for downloading images to workspace#99

Open
devin-ai-integration[bot] wants to merge 1 commit into
developfrom
devin/1782050706-image-search-save
Open

feat: Add save parameter to image_search for downloading images to workspace#99
devin-ai-integration[bot] wants to merge 1 commit into
developfrom
devin/1782050706-image-search-save

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Adds an optional save: Bool parameter to image_search (default false). When true, after fetching SerpAPI results and rendering the gallery as usual, the skill downloads each image's full-size original URL and persists it to the iCloud Drive workspace under downloads/images/<sanitized_query>_<index>.jpg.

Key design points:

  • Additive, not a replacementsave: false (default) is identical to the old behavior. Gallery rendering is always intact.
  • Concurrent downloads via DispatchGroup — each image downloads in parallel with a 15s timeout. Failures (network errors, non-2xx, invalid URLs) are logged and skipped; the search never crashes.
  • Workspace integration — uses Workspace.shared.resolve + coordinatedWrite + coordinatedCreateDirectory so files land correctly on both iCloud and local-fallback backends.
  • Result includes saved paths — the tool result appends a Saved N image(s) to workspace: section with workspace-relative paths (e.g. downloads/images/golden_retriever_1.jpg) so the model can reference them or call share_file.
  • Filename sanitization — query → alphanumeric + _/-, capped at 60 chars. Extension derived from the source URL, defaulting to .jpg.
  • System prompt updated — instructs the model to pass save: true when users ask to save/download/keep images.

Link to Devin session: https://app.devin.ai/sessions/254ea52d907048e19130d26ef462e47e

…to workspace

Add an optional `save` boolean parameter to the image_search tool.
When save: true, downloads each image (full-size original URL, falling
back to thumbnail) and persists it to the iCloud Drive workspace under
downloads/images/ with filenames derived from the query.

- Tool schema updated with the new `save` parameter
- System prompt updated to instruct the model when to use save: true
- Downloads run concurrently via DispatchGroup, failures are skipped
  gracefully (logged, never crash the search)
- Saved file paths included in the tool result for model reference
- Gallery rendering unchanged when save is false (default)

Co-Authored-By: bot_apk <apk@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author
Original prompt from API User

Enhance the image_search tool in the LoopHarness iOS app so that when Google Image Search results (via SerpAPI) are returned and rendered as a thumbnail gallery, the user can also SAVE those images to the iCloud Drive workspace.

Current behavior: image_search calls SerpAPI's Google Images endpoint, gets back results (title, url, thumbnail/originalUrl), and renders them as an inline tappable gallery in the chat. The images are not persisted anywhere.

Desired behavior:

  1. Add an optional save boolean parameter to the image_search tool (default false). When save: true, after fetching results, download each image (the original/full-size URL if available, otherwise the thumbnail) and save it to the workspace under a folder like downloads/images/ with a sensible filename (e.g. image_search_&lt;query&gt;_&lt;index&gt;.jpg or based on the source domain).
  2. When images are saved, include the saved file paths in the tool result so the model can reference them (and use share_file if needed).
  3. If save is false (default), behavior is unchanged — just render the gallery as before.
  4. Make sure to handle download failures gracefully (skip failed images, don't crash the whole search).
  5. Keep the existing gallery rendering intact — saving is additive, not a replacement.

Look for the existing image_search implementation in the codebase (likely in a skills/tools directory). The SerpAPI integration should already be there. Build on top of it.

Add ashbhat as a reviewer on the PR.

Repository: theashbhat/LoopHarness

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
loop-harness Ready Ready Preview, Comment Jun 21, 2026 2:07pm

@devin-ai-integration devin-ai-integration Bot requested a review from ashbhat June 21, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants