Description
Channel handlers (telegram.go, line.go, slack.go, onebot.go) download media files to a local temp directory and then call HandleMessage, which publishes the message (including local file paths) to an async message bus via PublishInbound. However, each handler also has a defer os.Remove() that deletes those files when the handler function returns — before the agent loop goroutine has a chance to read them.
This race condition was originally identified by @DevEverything01 in #543.
Impact
Voice transcription, image analysis, and document processing via the agent loop silently fail because the files no longer exist by the time they are accessed.
Proposed Fix
- Remove the premature
defer os.Remove() from the four affected channel handlers.
- Introduce a background
MediaCleaner that periodically scans the temp media directory and removes files older than 30 minutes, preventing unbounded temp file accumulation.
Note: discord.go is not affected — it processes voice files synchronously before returning, so there is no race condition.
Description
Channel handlers (
telegram.go,line.go,slack.go,onebot.go) download media files to a local temp directory and then callHandleMessage, which publishes the message (including local file paths) to an async message bus viaPublishInbound. However, each handler also has adefer os.Remove()that deletes those files when the handler function returns — before the agent loop goroutine has a chance to read them.This race condition was originally identified by @DevEverything01 in #543.
Impact
Voice transcription, image analysis, and document processing via the agent loop silently fail because the files no longer exist by the time they are accessed.
Proposed Fix
defer os.Remove()from the four affected channel handlers.MediaCleanerthat periodically scans the temp media directory and removes files older than 30 minutes, preventing unbounded temp file accumulation.Note:
discord.gois not affected — it processes voice files synchronously before returning, so there is no race condition.