Skip to content

fix(im/wecom): preserve image in mixed messages with text captions - #3901

Open
loganv wants to merge 2 commits into
Tencent:mainfrom
loganv:fix/wecom-mixed-image
Open

loganv wants to merge 2 commits into
Tencent:mainfrom
loganv:fix/wecom-mixed-image

Conversation

@loganv

@loganv loganv commented Sep 30, 2026

Copy link
Copy Markdown

Description

WeCom long-connection adapter dropped the image whenever a mixed (text+image) message contained any text. The most common mixed-message shape — a question plus a screenshot — reached the QA pipeline as text-only, so the model never saw the image, despite the IM integration docs stating images are handled as QA attachments.

convertMixedMessage now keeps the first image as the message attachment and carries the text as its caption (MessageTypeImage + Content). The IM service already supports captioned images: prepareIMAttachments downloads the file while fileMessageQAContent preserves msg.Content as the query, so no changes outside the wecom adapter are needed.

Text-only, image-only, and empty mixed messages keep their previous behavior. Multiple images still collapse to the first one — supporting several attachments requires a multi-attachment IncomingMessage and is left out of this minimal fix.

Type of Change

  • 🐛 Bug fix

Related Issue

Fixes #

Testing

  • New table-driven tests in internal/im/wecom/mixed_test.go covering: text+image, multiple images with text, text-only, image-only, group-chat @mention stripping, and empty mixed message
  • go test ./internal/im/wecom/ — pass
  • go test ./internal/im/... (all platform adapters: feishu, slack, telegram, mattermost, qqbot, yunzhijia, wecom) — pass, no regression
  • go vet ./internal/im/wecom/ — clean
  • gofmt -l internal/im/wecom/ — clean
  • git diff --check origin/main...HEAD — clean

Checklist

  • git diff --check origin/main...HEAD passes
  • Changed source files are formatted
  • Targeted tests for the changed packages/components pass
  • Diff-scoped lint passes where applicable (for Go: golangci-lint run --new-from-rev=origin/main ./...)
  • Full-repository checks were run, or any unrelated/environment-dependent failures are documented above
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation (README, website-docs/, Swagger annotations, etc.)
  • Breaking changes are clearly called out in the description above

Note: golangci-lint is not installed locally on this machine (network-restricted environment); the change is gofmt/go vet clean and covered by unit tests. The behavior now matches what website-docs/03-features/12-im-integration.md already documents (fileMessageQAContent caption path), so no doc update is needed.

convertMixedMessage discarded the image whenever a mixed (text+image)
message contained any text, so the most common shape — a question plus
a screenshot — reached the QA pipeline as text-only and the model never
saw the image, despite the IM integration docs promising images are
handled as QA attachments.

Keep the first image as the message attachment and carry the text as
its caption: the IM service already supports captioned images
(prepareIMAttachments downloads the file while fileMessageQAContent
preserves msg.Content as the query), so the adapter just has to emit
MessageTypeImage with Content set instead of MessageTypeText.

Text-only, image-only, and empty mixed messages keep their previous
behavior. Multiple images still collapse to the first one; supporting
several attachments requires a multi-attachment IncomingMessage and is
left out of this minimal fix.

This branch has not been deployed

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

1 participant