Skip to content

Wait to run the Agent first step until Input guardrails is complete #394

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
wants to merge 1 commit into from

Conversation

rach
Copy link

@rach rach commented Mar 29, 2025

The guardrail may trigger a Tripewire but the agent still run

In v0.0.7, the code runs the input guardrail task and the agent's first step together asynchronously.

If the guardrail is in place to avoid a side effect from the Agent run, the agent may still do something unexpected.

Let's say that you have a tripwire guardrail: "Don't allow to delete a file", and the agent is an MCP file system agent

…ripwire

In v0.0.7, the code runs the input guardrail task and the agent's first step together asynchronously. 

If the guardrail is in place to avoid a side effect from the Agent run, there is a risk that the agent still does something unexpected.
@rach rach changed the title Avoid to run the Agent first step before Input guardrails finished Wait to run the Agent first step until Input guardrails is complete Mar 29, 2025
@rm-openai
Copy link
Collaborator

the current behavior is the intended/documented behavior. If you want to run the guardrail before the agent runs, you can just do that via python code:

triggered = await do_something()
if not triggered:
  await Runner.run(...)

@rm-openai rm-openai closed this Apr 1, 2025
@rach
Copy link
Author

rach commented Apr 5, 2025

For my own understanding. What was the rational to have the agent start before the guardrail is done?
I can work around it, now that I know the behavior.

@rm-openai
Copy link
Collaborator

@rach for latency. If the guardrail doesn't fail, then you will have made a bunch of progress on the actual agent. RUnning (guardrail, agent) in parallel is much faster than serially

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

Successfully merging this pull request may close these issues.

2 participants