File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -928,7 +928,9 @@ async def _run_input_guardrails_with_queue(
928928 t .cancel ()
929929 raise
930930
931- streamed_result .input_guardrail_results = guardrail_results
931+ streamed_result .input_guardrail_results = (
932+ streamed_result .input_guardrail_results + guardrail_results
933+ )
932934
933935 @classmethod
934936 async def _start_streaming (
@@ -1029,7 +1031,7 @@ async def _start_streaming(
10291031 ]
10301032 parallel_guardrails = [g for g in all_input_guardrails if g .run_in_parallel ]
10311033
1032- # Run sequential guardrails first (will raise exception if tripwire triggered) .
1034+ # Run sequential guardrails first.
10331035 if sequential_guardrails :
10341036 await cls ._run_input_guardrails_with_queue (
10351037 starting_agent ,
@@ -1039,6 +1041,10 @@ async def _start_streaming(
10391041 streamed_result ,
10401042 current_span ,
10411043 )
1044+ # Check if any blocking guardrail triggered and raise before starting agent.
1045+ for result in streamed_result .input_guardrail_results :
1046+ if result .output .tripwire_triggered :
1047+ raise InputGuardrailTripwireTriggered (result )
10421048
10431049 # Run parallel guardrails in background.
10441050 streamed_result ._input_guardrails_task = asyncio .create_task (
You can’t perform that action at this time.
0 commit comments