Skip to content

feat(opencode): add trigger words for inline image attachments#29097

Open
divitkashyap wants to merge 1 commit into
anomalyco:devfrom
divitkashyap:feat/inline-image-trigger-words
Open

feat(opencode): add trigger words for inline image attachments#29097
divitkashyap wants to merge 1 commit into
anomalyco:devfrom
divitkashyap:feat/inline-image-trigger-words

Conversation

@divitkashyap
Copy link
Copy Markdown

@divitkashyap divitkashyap commented May 24, 2026

Issue for this PR

Closes #21585

Type of change

  • New feature

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:

  • `Screenshot 2026-…` → `[screenshot]`
  • `clipboard-…` → `[clipboard]`
  • `photo*` → `[photo]`
  • other images → `[image]`

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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Supersedes #21586 (auto-closed by cleanup). Rebased onto current `dev`.

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
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.

[FEATURE]: Inline image attachments don't include trigger text for skill auto-activation

1 participant