Description
Please read this first
-
Have you read the docs?
✅ Yes, I have read the [Agents SDK docs](https://openai.github.io/openai-agents-python/). -
Have you searched for related issues?
✅ Yes, I searched theopenai-agents-python
repo and did not find any existing issue requesting this feature.
Describe the feature
👉 What is the feature you're requesting?
I’m requesting an option in the SDK to control the execution mode of guardrails. Specifically, I propose adding a way to choose whether guardrails run:
- In parallel with the agent (the current default behavior)
- Sequentially, where the agent only starts if the guardrails pass
👉 Examples:
If guardrail_mode="sequential"
or guardrails_first=True
is set:
- Guardrails would run and complete first.
- Only if the guardrails pass then the agent start generating tokens.
👉 Why is this useful?
- In the current design, guardrails and the agent run together using
asyncio.gather
. This is great for low latency, but can cause unnecessary cost if a guardrail trips, because by the time it does, the agent may have already generated tokens. - The proposed option would help in cases where cost efficiency is a priority (e.g., expensive models, stricter validation requirements).
- This would give developers control over the trade-off between speed and cost protection, depending on their use case.
👉 Important note:
This request is not a complaint about the current design, the current parallel execution is great for most use cases where speed is the top priority. This is about adding flexibility for cost-sensitive scenarios.
Thank you for considering this feature request!