feat(opencode): add trigger words for inline image attachments#29097
Open
divitkashyap wants to merge 1 commit into
Open
feat(opencode): add trigger words for inline image attachments#29097divitkashyap wants to merge 1 commit into
divitkashyap wants to merge 1 commit into
Conversation
Skills like vision-analysis auto-activate based on trigger words in the user's message text (e.g. "screenshot", "describe", "analyze"). Inline images sent to the LLM only include the file part with no surrounding text, so those skills never see anything to match against. Extract a trigger word from the filename before pushing a media file part to the model message: Screenshot 2026-04-08 at 2.54.51 pm.png -> [screenshot] clipboard-2026-05.png -> [clipboard] photo.jpg -> [photo] other images -> [image] Refs anomalyco#21514
Closed
1 task
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 #21585
Type of change
What does this PR do?
Skills like `vision-analysis` auto-activate based on trigger words in the user's text. Inline image attachments only send a `file` part to the model — no surrounding text — so those skills never see anything to match against and the agent ends up giving a confused fallback reply.
In `packages/opencode/src/session/message-v2.ts`, when pushing a media file part for the model, also push a small text part containing a trigger word derived from the filename:
Mirrors how the existing `stripMedia` branch already injects an `[Attached : ]` text part.
How did you verify your code works?
`packages/opencode/test/session/message-v2.test.ts` was updated to expect the new `[image]` text part alongside the file part in the inline-image test case. Logic-checked against the existing branch immediately above (`stripMedia`) which already follows the same shape.
Checklist
Supersedes #21586 (auto-closed by cleanup). Rebased onto current `dev`.