Skip to content

Commit e67bcdf

Browse files
committed
fix: Increase retries for Gateway client
1 parent 4d37967 commit e67bcdf

File tree

6 files changed

+46
-4
lines changed

6 files changed

+46
-4
lines changed

examples/servers/book-search/gateway_setup/setup_gateway.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import os
55
import boto3
6+
from botocore.config import Config
67
from bedrock_agentcore_starter_toolkit.operations.gateway.client import GatewayClient
78

89

@@ -53,6 +54,16 @@ def main():
5354

5455
# Create Gateway client for us-west-2
5556
gateway_client = GatewayClient(region_name="us-west-2")
57+
retry_config = Config(
58+
retries={
59+
"max_attempts": 10,
60+
"mode": "standard",
61+
}
62+
)
63+
boto_client = boto3.client(
64+
"bedrock-agentcore-control", region_name="us-west-2", config=retry_config
65+
)
66+
gateway_client.client = boto_client
5667

5768
# Create Gateway
5869
role_arn = f"arn:aws:iam::{account_id}:role/mcp-lambda-example-agentcore-gateways"

examples/servers/book-search/gateway_setup/teardown_gateway.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import os
55
import boto3
6+
from botocore.config import Config
67

78

89
def main():
@@ -23,8 +24,14 @@ def main():
2324
return
2425

2526
# Delete all gateway targets
27+
retry_config = Config(
28+
retries={
29+
"max_attempts": 10,
30+
"mode": "standard",
31+
}
32+
)
2633
agentcore_client = boto3.client(
27-
"bedrock-agentcore-control", region_name="us-west-2"
34+
"bedrock-agentcore-control", region_name="us-west-2", config=retry_config
2835
)
2936

3037
targets = agentcore_client.list_gateway_targets(gatewayIdentifier=gateway_id)

examples/servers/dictionary/gateway_setup/setup-gateway.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ async function main() {
7272
};
7373

7474
// Create Gateway
75-
const agentCoreClient = new BedrockAgentCoreControlClient({ region });
75+
const agentCoreClient = new BedrockAgentCoreControlClient({
76+
region,
77+
maxAttempts: 10,
78+
});
7679
const roleArn = `arn:aws:iam::${accountId}:role/mcp-lambda-example-agentcore-gateways`;
7780

7881
const gateway = await agentCoreClient.send(

examples/servers/dictionary/gateway_setup/teardown-gateway.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ async function main() {
3838
throw error;
3939
}
4040

41-
const agentCoreClient = new BedrockAgentCoreControlClient({ region });
41+
const agentCoreClient = new BedrockAgentCoreControlClient({
42+
region,
43+
maxAttempts: 10,
44+
});
4245

4346
// Delete all gateway targets
4447
const targets = await agentCoreClient.send(

examples/servers/inspiration/setup_gateway.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import os
55
import boto3
6+
from botocore.config import Config
67
from bedrock_agentcore_starter_toolkit.operations.gateway.client import GatewayClient
78

89

@@ -39,6 +40,16 @@ def main():
3940

4041
# Create Gateway client for us-west-2
4142
gateway_client = GatewayClient(region_name="us-west-2")
43+
retry_config = Config(
44+
retries={
45+
"max_attempts": 10,
46+
"mode": "standard",
47+
}
48+
)
49+
boto_client = boto3.client(
50+
"bedrock-agentcore-control", region_name="us-west-2", config=retry_config
51+
)
52+
gateway_client.client = boto_client
4253

4354
# Create Gateway
4455
role_arn = f"arn:aws:iam::{account_id}:role/mcp-lambda-example-agentcore-gateways"

examples/servers/inspiration/teardown_gateway.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import os
55
import boto3
6+
from botocore.config import Config
67

78

89
def main():
@@ -23,8 +24,14 @@ def main():
2324
return
2425

2526
# Delete all gateway targets
27+
retry_config = Config(
28+
retries={
29+
"max_attempts": 10,
30+
"mode": "standard",
31+
}
32+
)
2633
agentcore_client = boto3.client(
27-
"bedrock-agentcore-control", region_name="us-west-2"
34+
"bedrock-agentcore-control", region_name="us-west-2", config=retry_config
2835
)
2936

3037
targets = agentcore_client.list_gateway_targets(gatewayIdentifier=gateway_id)

0 commit comments

Comments
 (0)