@@ -181,7 +181,6 @@ def _do_upload(self, on_progress: Callable[[int, int], None] | None = None) -> N
181181
182182 # Step 2: Upload screenshots separately
183183 if screenshots :
184- print (f"📸 [Sentience] Uploading { len (screenshots )} screenshots..." )
185184 self ._upload_screenshots (screenshots , on_progress )
186185
187186 # Step 3: Create cleaned trace file (without screenshot_base64)
@@ -505,16 +504,31 @@ def _request_screenshot_urls(self, sequences: list[int]) -> dict[int, str]:
505504 data = response .json ()
506505 # Gateway returns sequences as strings in JSON, convert to int keys
507506 upload_urls = data .get ("upload_urls" , {})
508- return {int (k ): v for k , v in upload_urls .items ()}
507+ result = {int (k ): v for k , v in upload_urls .items ()}
508+ if self .logger :
509+ self .logger .info (f"Received { len (result )} screenshot upload URLs" )
510+ return result
509511 else :
512+ error_msg = f"Failed to get screenshot URLs: HTTP { response .status_code } "
510513 if self .logger :
511- self .logger .warning (
512- f"Failed to get screenshot URLs: HTTP { response .status_code } "
513- )
514+ self .logger .warning (error_msg )
515+ else :
516+ print (f" ⚠️ { error_msg } " )
517+ # Try to get error details
518+ try :
519+ error_data = response .json ()
520+ error_detail = error_data .get ("error" ) or error_data .get ("message" , "" )
521+ if error_detail :
522+ print (f" Error: { error_detail } " )
523+ except Exception :
524+ print (f" Response: { response .text [:200 ]} " )
514525 return {}
515526 except Exception as e :
527+ error_msg = f"Error requesting screenshot URLs: { e } "
516528 if self .logger :
517- self .logger .warning (f"Error requesting screenshot URLs: { e } " )
529+ self .logger .warning (error_msg )
530+ else :
531+ print (f" ⚠️ { error_msg } " )
518532 return {}
519533
520534 def _upload_screenshots (
@@ -540,11 +554,18 @@ def _upload_screenshots(
540554
541555 # 1. Request pre-signed URLs from gateway
542556 sequences = sorted (screenshots .keys ())
557+ print (f" Requesting upload URLs for { len (sequences )} screenshot(s)..." )
543558 upload_urls = self ._request_screenshot_urls (sequences )
544559
545560 if not upload_urls :
546561 print ("⚠️ [Sentience] No screenshot upload URLs received, skipping upload" )
562+ print (" This may indicate:" )
563+ print (" - API key doesn't have permission for screenshot uploads" )
564+ print (" - Gateway endpoint /v1/screenshots/init returned an error" )
565+ print (" - Network issue connecting to gateway" )
547566 return
567+
568+ print (f" ✅ Received { len (upload_urls )} upload URL(s) from gateway" )
548569
549570 # 2. Upload screenshots in parallel
550571 uploaded_count = 0
@@ -566,6 +587,11 @@ def upload_one(seq: int, url: str) -> bool:
566587 self .screenshot_total_size_bytes += image_size
567588
568589 # Upload to pre-signed URL
590+ # Extract the base URL for logging (without query params)
591+ upload_base_url = url .split ('?' )[0 ] if '?' in url else url
592+ if self .verbose if hasattr (self , 'verbose' ) else False :
593+ print (f" 📤 Uploading screenshot { seq } ({ image_size / 1024 :.1f} KB) to: { upload_base_url [:80 ]} ..." )
594+
569595 response = requests .put (
570596 url ,
571597 data = image_bytes , # Binary image data
@@ -576,16 +602,34 @@ def upload_one(seq: int, url: str) -> bool:
576602 )
577603
578604 if response .status_code == 200 :
605+ if self .logger :
606+ self .logger .info (f"Screenshot { seq } uploaded successfully ({ image_size / 1024 :.1f} KB)" )
607+ else :
608+ # Extract base URL for logging (without query params for security)
609+ upload_base = url .split ('?' )[0 ] if '?' in url else url
610+ upload_base_short = upload_base [:80 ] + "..." if len (upload_base ) > 80 else upload_base
611+ print (f" ✅ Screenshot { seq } uploaded: { image_size / 1024 :.1f} KB, format={ format_str } , URL={ upload_base_short } " )
579612 return True
580613 else :
614+ error_msg = f"Screenshot { seq } upload failed: HTTP { response .status_code } "
581615 if self .logger :
582- self .logger .warning (
583- f"Screenshot { seq } upload failed: HTTP { response .status_code } "
584- )
616+ self .logger .warning (error_msg )
617+ else :
618+ print (f" ⚠️ { error_msg } " )
619+ # Try to get error details from response
620+ try :
621+ error_detail = response .text [:200 ]
622+ if error_detail :
623+ print (f" Response: { error_detail } " )
624+ except Exception :
625+ pass
585626 return False
586627 except Exception as e :
628+ error_msg = f"Screenshot { seq } upload error: { e } "
587629 if self .logger :
588- self .logger .warning (f"Screenshot { seq } upload error: { e } " )
630+ self .logger .warning (error_msg )
631+ else :
632+ print (f" ⚠️ { error_msg } " )
589633 return False
590634
591635 # Upload in parallel (max 10 concurrent)
@@ -605,7 +649,10 @@ def upload_one(seq: int, url: str) -> bool:
605649
606650 # 3. Report results
607651 if uploaded_count == total_count :
608- print (f"✅ [Sentience] All { total_count } screenshots uploaded successfully" )
652+ total_size_mb = self .screenshot_total_size_bytes / 1024 / 1024
653+ print (f"✅ [Sentience] All { total_count } screenshots uploaded successfully!" )
654+ print (f" 📊 Total screenshot size: { total_size_mb :.2f} MB" )
655+ print (f" 📸 Screenshots are now available in cloud storage" )
609656 else :
610657 print (f"⚠️ [Sentience] Uploaded { uploaded_count } /{ total_count } screenshots" )
611658 if failed_sequences :
0 commit comments