[Bug] UnboundLocalError: cannot access local variable 'img_type' where it is not associated with a value during image upload
tsah-balance opened this issue · comments
Description
When attempting to upload an image to an Agno agent, the framework throws an UnboundLocalError indicating that the variable img_type is being referenced before it has been assigned a value. This error occurs within Agno's internal image processing code and prevents any image upload functionality from working
Steps to Reproduce
- Create a basic Agno agent with image support
- Attempt to upload an image using the agent
- Error is thrown during image processing
Agent Configuration (if applicable)
agent = Agent(
name="Agent",
model=Claude(id="claude-sonnet-4-20250514"),
description=(
".."
),
instructions=[INSTRUCTIONS],
db=db, # Supabase DB
add_history_to_context=True,
num_history_runs=20,
markdown=True,
session_id=session_id,
user_id=user_id,
enable_session_summaries=True,
# Image handling configuration
send_media_to_model=True, # Send images to Claude for analysis
store_media=True, # Persist images in database with session history
)
Expected Behavior
The agent should:
- Successfully accept the image input (either as a file path, URL, or base64 string)
- Process the image internally and pass it to the underlying LLM
- Return a response analyzing or describing the image content
- Complete the operation without any errors
Actual Behavior
The agent fails to process the image and raises an UnboundLocalError:
ERROR Error processing image: cannot access local variable
'img_type' where it is not associated with a value
Screenshots or Logs (if applicable)
No response
Environment
Agno Version: 2.2.10
Python Version: 3.11.9
Model Provider: claude-sonnet-4-20250514
Image Format: JPEG, PNGPossible Solutions (optional)
No response
Additional Context
- The error persists even after upgrading to the latest version of Agno
- The issue occurs with both local file paths and base64-encoded images
- Tested with different image sizes and encodings - all produce the same error
- This also happnes when using the Agno os UI (and not my custom UI)
Thanks for reporting this @tsah-balance. We have a fix and will try to release it asap!