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 @@ -981,7 +981,9 @@ async def _run_input_guardrails_with_queue(
981981 t .cancel ()
982982 raise
983983
984- streamed_result .input_guardrail_results = guardrail_results
984+ streamed_result .input_guardrail_results = (
985+ streamed_result .input_guardrail_results + guardrail_results
986+ )
985987
986988 @classmethod
987989 async def _start_streaming (
@@ -1082,7 +1084,7 @@ async def _start_streaming(
10821084 ]
10831085 parallel_guardrails = [g for g in all_input_guardrails if g .run_in_parallel ]
10841086
1085- # Run sequential guardrails first (will raise exception if tripwire triggered) .
1087+ # Run sequential guardrails first.
10861088 if sequential_guardrails :
10871089 await cls ._run_input_guardrails_with_queue (
10881090 starting_agent ,
@@ -1092,6 +1094,10 @@ async def _start_streaming(
10921094 streamed_result ,
10931095 current_span ,
10941096 )
1097+ # Check if any blocking guardrail triggered and raise before starting agent.
1098+ for result in streamed_result .input_guardrail_results :
1099+ if result .output .tripwire_triggered :
1100+ raise InputGuardrailTripwireTriggered (result )
10951101
10961102 # Run parallel guardrails in background.
10971103 streamed_result ._input_guardrails_task = asyncio .create_task (
You can’t perform that action at this time.
0 commit comments