feat(opencode): add trigger words for inline image attachments#21586
Open
divitkashyap wants to merge 4 commits intoanomalyco:devfrom
Open
feat(opencode): add trigger words for inline image attachments#21586divitkashyap wants to merge 4 commits intoanomalyco:devfrom
divitkashyap wants to merge 4 commits intoanomalyco:devfrom
Conversation
The message.role type only allows 'user' or 'assistant', so checking for 'system' role was redundant. Removed the conditional to show all non-system messages in fork dialog.
When sending inline images to the LLM, extract trigger words from the filename to help skills like vision-analysis auto-activate. For filenames containing "screenshot", "clipboard", or "photo", prepend the matching trigger word as a text part before the file part. Fallback to "image" for other image types. Fixes anomalyco#21514
Author
|
I've updated the PR description to follow the template. Could you please re-check if it now meets the requirements? The description now includes: Issue for this PR, Type of change, What does this PR do, How did you verify, and Checklist sections. |
The feature adds trigger text before inline image file parts to help skills auto-activate. Updated test expectations accordingly.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #21514
Type of change
What does this PR do?
Skills like
vision-analysisauto-activate based on trigger words in the message text (like "screenshot", "describe", "analyze"). However, inline images sent to the LLM only include the file part without surrounding text context, so these skills never activate.This PR adds trigger word extraction from the filename before sending inline image parts:
Screenshot 2026-04-08 at 2.54.51 pm.png→ prepends[screenshot]clipboard-2026-05.png→ prepends[clipboard]photo.jpg→ prepends[photo][image]The change is in
packages/opencode/src/session/message-v2.ts- when sending a media file part to the LLM, we now first extract a trigger word from the filename and prepend it as a text part.How did you verify your code works?
The code compiles successfully. The fix follows the existing pattern in the file where
stripMediaalready adds text for images. Manual testing would involve sending an inline screenshot and verifying the vision-analysis skill activates.Checklist