mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-20 02:17:24 +00:00
Without these tags the Bitrix-borne PDF / audio / image arrive as bare text to the agent loop: the LLM never realizes an attachment exists and degrades to "no file attached" replies (or worse, hallucinates a CRM document id and fires crm.documentgenerator at it). The other channels (Telegram, Slack, Discord) all prepend <media:*> tags before publish via the shared media.BuildMediaTags helper — Bitrix24 was the lone holdout. The agent loop's enrichInputMedia REPLACES tags it finds (it does NOT insert new ones), so adding the tag at the channel boundary is the fix that aligns Bitrix with the other channels AND unlocks enrich's read_document / read_audio / read_image routing downstream. - media_tags.go: mediaFilesToInfos() adapter from bus.MediaFile to media.MediaInfo + classifyMediaType() MIME prefix → media.Type* mapping. Unknown MIMEs fall back to TypeDocument (read_document handles generic binaries safely; a bogus audio tag on a non-audio file would mislead the LLM). Bitrix ships voice notes as audio/* — they're classified as TypeAudio (read_audio handles both audio and voice identically). - handle.go: prepend BuildMediaTags(...) output to text right before HandleMessageMedia. No-op when no media files. - media_tags_test.go: pins the MIME map, the conversion, and the end-to-end tag shape through BuildMediaTags. Surface parity: backend-only. No API / web UI / CLI impact. Co-authored-by: DangTinh311 <dangtinh31193@gmail.com>