From 5006a9ea60c205eddc500d6945dd3ee4e2d9c476 Mon Sep 17 00:00:00 2001 From: diexoff Date: Sat, 30 May 2026 10:30:40 +0000 Subject: [PATCH] fix: pass image data to Claude in handle_photo (classic mode) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #168 added multimodal support in sdk_integration.py and facade.py but forgot to wire images= in the classic-mode handle_photo handler. Images were downloaded and base64-encoded but only a text prompt was sent to Claude — the actual photo was never seen. This reads the detected format from ProcessedImage.metadata, maps it to the correct MIME type, and passes the base64 payload via images= so Claude receives the photo as a multimodal content block. Co-Authored-By: Claude Sonnet 4.6 --- src/bot/handlers/message.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/bot/handlers/message.py b/src/bot/handlers/message.py index bbd240840..49be4b52f 100644 --- a/src/bot/handlers/message.py +++ b/src/bot/handlers/message.py @@ -938,6 +938,22 @@ async def handle_photo(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No ) session_id = context.user_data.get("claude_session_id") + # Build image payload for Claude's multimodal API + fmt = ( + processed_image.metadata.get("format", "jpeg") + if processed_image.metadata + else "jpeg" + ) + media_type_map = { + "png": "image/png", + "gif": "image/gif", + "webp": "image/webp", + } + media_type = media_type_map.get(fmt, "image/jpeg") + image_payload = [ + {"data": processed_image.base64_data, "media_type": media_type} + ] + # Process with Claude try: claude_response = await claude_integration.run_command( @@ -945,6 +961,7 @@ async def handle_photo(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No working_directory=current_dir, user_id=user_id, session_id=session_id, + images=image_payload, ) # Update session ID