fix(media): persist generated files, prevent duplicate delivery, and improve group media history#206
Open
vanducng wants to merge 4 commits intonextlevelbuilder:mainfrom
Open
Conversation
Root cause: dispatch.go deleted ALL media files after channel send, including workspace-generated files (create_image, create_video, etc.). This caused "stat file: no such file" errors on subsequent send attempts and prevented files from persisting in workspace storage. Additionally, when the LLM used the message tool with MEDIA: prefix to send generated media, the same file was sent again via RunResult.Media, causing duplicate images/videos in channel chats. Changes: - dispatch.go: only delete temp files (/tmp/), not workspace files - loop.go: track media sent by message tool, deduplicate RunResult.Media - create_image/video/audio: add empty data guard, post-write verification with size logging for diagnostics - send_helpers.go: log directory contents on stat failure for debugging
…Zalo
- media_tool_routing: support chain format {"providers":[...]} in
hasReadImageProvider (was only flat {"provider":"X"})
- history: add Media field to HistoryEntry, CollectMedia() for pending
entries, temp file cleanup on eviction/clear
- discord/handler: record media in group history, collect on @mention
- zalo/personal/handlers: same pattern for Zalo group history
910bb09 to
c69394c
Compare
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.
Summary
dispatch.godeleted ALL media files after channel send, including workspace-generated files (create_image,create_video,create_audio). This causedstat file: no such fileerrors and prevented files from persisting in workspace storage.messagetool (MEDIA:prefix), the same file was also sent viaRunResult.Media, causing duplicate images/videos in channel chats. Previously masked by the file deletion bug.hasReadImageProvideronly supported flat{"provider":"X"}format, not the chain format{"providers":[...]}used by media provider chain config.Changes
Fix: Media file persistence & dedup
dispatch.go/tmp/), not workspace filesloop.gomessagetool, deduplicateRunResult.Mediacreate_image.gocreate_video.gocreate_audio.gosend_helpers.goFeat: Chain provider format + group media history
media_tool_routing.go{"providers":[...]}inhasReadImageProviderhistory.goMediafield toHistoryEntry,CollectMedia(), temp file cleanup on eviction/cleardiscord/handler.gozalo/personal/handlers.goTest plan
stat file: no such fileerrors in logs/tmp/still cleaned up after send