8ac5e90ec2
After context compression, the agent re-sent an already-delivered generated image on every subsequent turn (#46627). The auto-append fallback rescans full history when the message list shrinks (compression- safe path), deduping against _history_media_paths — but that set was built by scanning ONLY MEDIA: text tags in tool results. image_generate returns its path in a JSON payload field (host_image/image/agent_visible_image), never a MEDIA: tag, so generated-image paths never entered the dedup set and were re-emitted after the boundary. Extract the history-path collection into _collect_history_media_paths(), which now covers BOTH delivery shapes: MEDIA: text tags AND image_generate JSON-payload paths (mirroring what _collect_auto_append_media_tags extracts). The inline block in _handle_message is replaced with a call to the helper. Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>