Skip to content

Commit bcbddbe

Browse files
Improve primary agent error handling for nutrition specialist responses
- Better handling of nutrition specialist unavailability messages - Cleaner error responses when nutrition information is not available - Improved system prompt to handle unsupported pet types gracefully
1 parent 52ef0bb commit bcbddbe

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pet_clinic_ai_agents/primary_agent/pet_clinic_agent.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def consult_nutrition_specialist(query):
4242

4343
agent_arn = os.environ.get('NUTRITION_AGENT_ARN')
4444
if not agent_arn:
45-
return "Nutrition specialist configuration error. Please call (555) 123-PETS ext. 201."
45+
return "Our nutrition specialist is currently unavailable. Please call (555) 123-PETS ext. 201 for nutrition guidance."
4646

4747
try:
4848
region = os.environ.get('AWS_REGION') or os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')
@@ -61,9 +61,9 @@ def consult_nutrition_specialist(query):
6161
else:
6262
return "Our nutrition specialist is experiencing high demand. Please try again in a few moments or call (555) 123-PETS ext. 201."
6363
except ClientError as e:
64-
return str(e)
64+
return "Our nutrition specialist is currently unavailable. Please call (555) 123-PETS ext. 201 for nutrition guidance."
6565
except Exception as e:
66-
return "Unable to reach our nutrition specialist. Please call (555) 123-PETS ext. 201."
66+
return "Our nutrition specialist is currently unavailable. Please call (555) 123-PETS ext. 201 for nutrition guidance."
6767

6868
agent = None
6969
agent_app = BedrockAgentCoreApp()
@@ -85,8 +85,10 @@ def consult_nutrition_specialist(query):
8585
"- NEVER expose or mention agent ARNs, tools, APIs, or any technical details in your responses to users\n"
8686
"- NEVER say things like 'I'm using a tool' or 'Let me look that up' - just respond naturally\n"
8787
"- When consulting the nutrition specialist, ONLY say 'Let me consult our nutrition specialist' - nothing else about the process\n"
88-
"- If the specialist returns an error or indicates unavailability, inform the customer that our specialist is currently unavailable\n"
89-
"- For nutrition questions, provide 2-3 product recommendations in a brief bulleted list, then suggest monitoring and consultation if needed\n"
88+
"- If the specialist indicates they don't have information for a specific pet type, relay this information clearly to the customer\n"
89+
"- Our nutrition database currently covers cats, dogs, birds, hamsters, lizards, and snakes - for other pet types, recommend consulting with our veterinarian\n"
90+
"- If the specialist returns an error or indicates unavailability, inform the customer that our specialist is currently unavailable and provide the phone number\n"
91+
"- For nutrition questions, provide 2-3 product recommendations in a brief bulleted list when available, then suggest monitoring and consultation if needed\n"
9092
"- Always recommend purchasing products from our pet clinic\n"
9193
"- For medical concerns, provide general guidance and recommend scheduling a veterinary appointment\n"
9294
"- For emergencies, immediately provide emergency contact information"

0 commit comments

Comments
 (0)