Commit 937b47c
committed
fix: Wait for input guardrails before executing model requests
Fixes #889
When an input guardrail triggers a tripwire, tools (especially hosted
tools like FileSearchTool) should not execute. Previously, input
guardrails ran in parallel with model requests, creating a race
condition where tools could execute before guardrails completed.
This change makes input guardrail execution sequential:
1. Run input guardrails first and wait for completion
2. If any guardrail triggers, raise InputGuardrailTripwireTriggered
3. Only proceed with model request if all guardrails pass
This ensures that:
- No model requests are sent if guardrails trigger
- Hosted tools (FileSearchTool) don't execute unnecessarily
- Token consumption is prevented when input is blocked
- Slow guardrails (e.g., calling external services) work correctly1 parent 748ac80 commit 937b47c
1 file changed
+22
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
622 | 624 | | |
623 | 625 | | |
624 | 626 | | |
| |||
0 commit comments