Skip to content

Add Option to Configure Guardrail Execution Mode (Sequential vs Parallel) #2411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
Hamza123545 opened this issue Jun 14, 2025 · 1 comment
Closed
1 task done

Comments

@Hamza123545
Copy link

Confirm this is a feature request for the Python library and not the underlying OpenAI API.

  • This is a feature request for the Python library

Describe the feature or improvement you're requesting

Summary:

Currently, the OpenAI Agents SDK runs guardrails and agent logic in parallel, prioritizing low latency. While this is a smart design for speed, it can cause token waste if the guardrail raises an error after the agent has already started running.


Problem:

The documentation says:

“If the guardrail detects malicious usage, it can immediately raise an error, which stops the expensive model from running and saves you time/money.”

However, in practice:

  • Guardrails and agent run in parallel
  • Tokens are already consumed before the guardrail finishes
  • So it does not actually save cost, and the doc feels misleading

Suggestion:

Please add a config option like this:

agent = Agent(
    guardrail_mode="parallel"  # Default (current behavior)
    # or
    guardrail_mode="sequential"  # Run guardrail first, then agent
)



This would let developers choose between:

Speed-first use cases (chatbots etc.)

Safety and cost-first use cases (finance, education, critical apps)

Why It Matters:
Flexibility is power. Different use cases need different trade-offs.
Giving this small config would make the SDK much more powerful and customizable.

Demo Video:
🎥 (https://drive.google.com/file/d/1JQPPz1hta7usMcxXA78GnqioFw09zc6B/view?usp=sharing)

Final Thought:
This is not a bug. It's a smart default.
But giving developers the choice will make it a great SDK for everyone.

Thank you for this amazing tool!

### Additional context

_No response_
@RobertCraigie
Copy link
Collaborator

This is not the agents repository, please report this there. https://github.com/openai/openai-agents-python

@RobertCraigie RobertCraigie closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants