generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 577
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
1.20.0
Python Version
3.12
Operating System
Windows 11
Installation Method
pip
Steps to Reproduce
- Import either strands tool from the community tool library.
from strands import Agent
from strands_tools import (
generate_image,
generate_image_stability,
)
agent = Agent(
tools = [generate_image, generate_image_stability]
)
agent("Generate image of a boat")
print(agent.messages)- Generate an image and log the agent.messages after the tool call completes (would recommend dumping to file)
Expected Behavior
Most users would expect that since the models are generating the image the actual image source would be under an "assistant" message not a "user" message.
Actual Behavior
Notice that the actual saved source bytes is a toolResult and thus saved under "user" rather than "assistant" though from a user perspective you would expect the generated image to be returned under the "assistant".
Here is an example:
{
"role": "assistant",
"content": [
{"text": "Let me try with the alternative image generation tool:"},
{"toolUse": {
"toolUseId": "tooluse_nOhPWosAQ5CqO7Lu-8kPJA",
"name": "generate_image",
"input": {
"prompt": "A brilliant shooting star streaking across a dark night sky, with a bright luminous trail behind it, stars scattered across the cosmic background, realistic and dramatic lighting",
"aspect_ratio": "16:9",
"model_id": "stability.stable-image-ultra-v1:1"
}
}}]
},
{
"role": "user",
"content": [
{
"toolResult": {
"toolUseId": "tooluse_nOhPWosAQ5CqO7Lu-8kPJA",
"status": "success",
"content": [{
"text": "The generated image has been saved locally to output\\a_brilliant_shooting_star_streaking.png. "
},
{
"image": {
"format": "jpeg",
"source": {
"bytes": {
"py/b64": "ACTUAL IMAGE BYTES"
}
}
}
}]
}
}
]
},
{
"role": "assistant",
"content": [{
"text": "Perfect! I've generated a beautiful image of a shooting star for you. The image shows a brilliant meteor streaking across a dark night sky with a luminous trail of blue, purple, and golden colors behind it. The shooting star is bright and dramatic against the starry cosmic background, creating a stunning celestial scene.\n\nThe image has been saved locally and displays the classic appearance of a shooting star (meteor) as it burns up in Earth's atmosphere, creating that characteristic bright streak we see in the night sky."
}]
}Additional Context
No response
Possible Solution
No response
Related Issues
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working