-
Notifications
You must be signed in to change notification settings - Fork 314
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
0.2.1
Python Version
3.12.5
Operating System
Ubuntu 22.04.5 LTS (Jammy Jellyfish)
Installation Method
pip
Steps to Reproduce
- Install
strands-agents
,strands-agents-tools
andpython-dotenv
packages. - Set AWS credentials (
aws_access_key_id
,aws_secret_access_key
,aws_session_token
) - Run provided code sample.
- You'll receive the following error.
botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the ConverseStream operation: This model doesn't support tool use in streaming mode.
└ Bedrock region: us-west-2
└ Model id: us.writer.palmyra-x5-v1:0
- [Optional] If you set
streaming=False
onBedrockModel
initialization and try to run this code again, you'll receive new error.
strands.types.exceptions.EventLoopException: An error occurred (ValidationException) when calling the Converse operation: This model doesn't support the status field. Remove status and try again.
Code sample:
import os
from boto3 import session
from dotenv import load_dotenv
from strands import Agent, tool
from strands.models import BedrockModel
from strands_tools import http_request
load_dotenv()
WEATHER_SYSTEM_PROMPT = """You are a weather assistant with HTTP capabilities. You can:
1. Make HTTP requests to the National Weather Service API
2. Process and display weather forecast data
3. Provide weather information for locations in the United States
When retrieving weather information:
1. First get the coordinates or grid information using [https://api.weather.gov/points/{latitude},{longitude}](https://api.weather.gov/points/%7Blatitude%7D,%7Blongitude%7D) or [https://api.weather.gov/points/{zipcode}](https://api.weather.gov/points/%7Bzipcode%7D)
2. Then use the returned forecast URL to get the actual forecast
When displaying responses:
- Format weather data in a human-readable way
- Highlight important information like temperature, precipitation, and alerts
- Handle errors appropriately
- Convert technical terms to user-friendly language
Always explain the weather conditions clearly and provide context for the forecast.
"""
@tool
def word_count(text: str) -> int:
"""Count words in text."""
return len(text.split())
bedrock_model = BedrockModel(
model_id="us.writer.palmyra-x5-v1:0",
boto_session=session.Session(
aws_access_key_id=os.getenv("aws_access_key_id", ""),
aws_secret_access_key=os.getenv("aws_secret_access_key", ""),
aws_session_token=os.getenv("aws_session_token", ""),
region_name="us-west-2",
),
# streaming=False, #uncomment to see new error
)
agent = Agent(
system_prompt=WEATHER_SYSTEM_PROMPT,
tools=[word_count, http_request],
model=bedrock_model,
)
response = agent(
"What's the weather like in Washington D.C? Also how many words are in the response?"
)
Expected Behavior
Receive an answer, not errors both for streaming/non-streaming modes.
Actual Behavior
Errors occurrence (explained in reproducing steps).
Additional Context
No response
Possible Solution
No response
Related Issues
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working