@@ -1625,29 +1625,14 @@ async def process_streamed_response(agent, conversation_input):
16251625 raise
16261626 else :
16271627 # Use non-streamed response
1628- from litellm .exceptions import Timeout
1629-
1630- max_retries = 3
1631- last_input = conversation_input
1632-
1633- for attempt in range (max_retries ):
1634- try :
1635- response = asyncio .run (Runner .run (agent , last_input ))
1636- break # Success, exit retry loop
1637- except Timeout as e :
1638- if attempt < max_retries - 1 :
1639- print (f"⏱️ Timeout on attempt { attempt + 1 } /{ max_retries } , retrying with 'continue'..." )
1640- last_input = "continue"
1641- else :
1642- print ("❌ Max retries reached" )
1643- raise
1644- except InputGuardrailTripwireTriggered as e :
1645- # Display a user-friendly warning for input guardrails
1646- reason = "Potential security threat detected in input"
1647- if hasattr (e , 'guardrail_result' ) and e .guardrail_result :
1648- if hasattr (e .guardrail_result , 'output' ) and e .guardrail_result .output :
1649- reason = e .guardrail_result .output .output_info .get ("reason" , reason )
1650- raise # Re-raise InputGuardrailTripwireTriggered
1628+ try :
1629+ response = asyncio .run (Runner .run (agent , conversation_input ))
1630+ except InputGuardrailTripwireTriggered as e :
1631+ # Display a user-friendly warning for input guardrails
1632+ reason = "Potential security threat detected in input"
1633+ if hasattr (e , 'guardrail_result' ) and e .guardrail_result :
1634+ if hasattr (e .guardrail_result , 'output' ) and e .guardrail_result .output :
1635+ reason = e .guardrail_result .output .output_info .get ("reason" , reason )
16511636
16521637 # Use red color for the warning message
16531638 print (f"\n \033 [91m🛡️ INPUT SECURITY GUARDRAIL TRIGGERED\033 [0m" )
0 commit comments