Uh oh!
There was an error while loading. Please reload this page.
fix: add run_in_parallel support to OutputGuardrail for sequential ex… - #4791
fix: add run_in_parallel support to OutputGuardrail for sequential ex…#4791Showmick119 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:5d570b4250
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| run_in_parallel: bool = True | ||
| """Whether the guardrail runs concurrently with other guardrails (True, default) or before | ||
| subsequent guardrails (False). |
There was a problem hiding this comment.
Honor sequential output guardrails in Realtime sessions
When these public guardrails are supplied through RealtimeAgent.output_guardrails or RealtimeRunConfig.output_guardrails, RealtimeSession._run_output_guardrails still awaits every guardrail in list order without consulting run_in_parallel (src/agents/realtime/session.py:1663-1669). Consequently, with an expensive default-parallel guardrail listed before a cheap run_in_parallel=False guardrail, the expensive check runs first and cannot be skipped when the cheap check trips—the exact cost-saving behavior this option promises works in Runner but is silently ignored on the supported Realtime path. Partition or otherwise honor the flag in that consumer as well.
AGENTS.md reference: AGENTS.md:L147-L147
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:50e1a5c498
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| triggered_results.append(result) | ||
| for t in tasks: | ||
| t.cancel() | ||
| break |
There was a problem hiding this comment.
Preserve all Realtime tripwire results
When two default-parallel Realtime output guardrails both trip, this break reports only the first result and ignores or cancels the others—even if multiple synchronous guardrail tasks have already completed. This regresses the public RealtimeGuardrailTripped.guardrail_results contract (documented as containing all triggered guardrails), and the follow-up message likewise omits their names; the pre-change caller-visible test explicitly covered both results. Preserve all parallel tripwire results before emitting the event while retaining the new sequential short-circuit behavior.
AGENTS.md reference: AGENTS.md:L147-L147
Useful? React with 👍 / 👎.
This pull request adds support for sequentially executing output guardrails to match the behavior of input guardrails.
Previously, OutputGuardrail did not have a run_in_parallel flag and run_output_guardrails always executed all output guardrails concurrently. This meant it was impossible to run a fast, low-cost guardrail (e.g., regex checks) before a slow, expensive one (e.g., an LLM judge) to trip the wire early and save tokens/time.