8000 fix: Merge strands-agents user agent into existing botocore config (#76) · KarmaENT/sdk-python@5f4b68a · GitHub
[go: up one dir, main page]

Skip to content

Commit 5f4b68a

Browse files
authored
fix: Merge strands-agents user agent into existing botocore config (strands-agents#76)
1 parent b21ea47 commit 5f4b68a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/strands/models/bedrock.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,21 @@ def __init__(
112112
session = boto_session or boto3.Session(
113113
region_name=region_name or os.getenv("AWS_REGION") or "us-west-2",
114114
)
115-
client_config = boto_client_config or BotocoreConfig(user_agent_extra="strands-agents")
115+
116+
# Add strands-agents to the request user agent
117+
if boto_client_config:
118+
existing_user_agent = getattr(boto_client_config, "user_agent_extra", None)
119+
120+
# Append 'strands-agents' to existing user_agent_extra or set it if not present
121+
if existing_user_agent:
122+
new_user_agent = f"{existing_user_agent} strands-agents"
123+
else:
124+
new_user_agent = "strands-agents"
125+
126+
client_config = boto_client_config.merge(BotocoreConfig(user_agent_extra=new_user_agent))
127+
else:
128+
client_config = BotocoreConfig(user_agent_extra="strands-agents")
129+
116130
self.client = session.client(
117131
service_name="bedrock-runtime",
118132
config=client_config,

0 commit comments

Comments
 (0)
0