-
Notifications
You must be signed in to change notification settings - Fork 560
Description
Please read this first
- Have you read the docs? Yes
- Have you searched for related issues? Yes
Describe the bug
Guardrail Execution Error example in the Exceptions section of the Running Agents guide doesn't work as expected.
Not sure if this is a bug or expected behavior, as there is a proper comment at
openai-agents-js/packages/agents-core/src/run.ts
Lines 1119 to 1120 in 5d9b751
| // Only run input guardrails on the first turn of a new run. | |
| if (result.state._currentTurn === 1 && !isResumingFromInterruption) { |
This behavior is also documented in the Guardrails guide as "Input guardrails run on the initial user input".
As per the comment, input guardrails only run on the first turn of a new run. So, I think the example is incorrect. I tend to do a fresh run using e.state._originalInput, but this isn't a good idea.
Suggestion - Rewriting the example to demonstrate the reuse of the runner's latest state with output guardrails is more realistic, as it is more common to have one input guardrail and multiple output guardrails in a single flow.
Debug information
- Agents SDK version: (e.g.
v0.0.1) - Runtime environment (e.g.
Node.js 22.16.0)
Repro steps
Run the example present in the docs, the fallbackGuardrail is not triggered.
Expected behavior
We expect the fallbackGuardrail to be triggered and we should get the expected output present in docs.
Guardrail execution failed: Error: Input guardrail failed to complete: Error: Something is wrong!
Math homework guardrail tripped