fix: stop streamed tool execution after known input guardrail tripwire#2688
fix: stop streamed tool execution after known input guardrail tripwire#2688
Conversation
c2d0c73 to
15a3045
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15a304514b
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f03cc1a5b
ℹ️ 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".
Co-authored-by: Codex <noreply@openai.com>
e85ae18 to
623000c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 623000cd98
ℹ️ 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".
| async def raise_if_input_guardrail_tripwire_known() -> None: | ||
| tripwire_result = streamed_result._triggered_input_guardrail_result | ||
| if tripwire_result is not None: | ||
| raise InputGuardrailTripwireTriggered(tripwire_result) |
There was a problem hiding this comment.
Append tripwire result before raising streamed guardrail exception
raise_if_input_guardrail_tripwire_known raises immediately when _triggered_input_guardrail_result is set, but run_input_guardrails_with_queue does not append that result to streamed_result.input_guardrail_results until after await asyncio.gather(...) finishes sibling cancellations. With a slow-cancel sibling, callers receive InputGuardrailTripwireTriggered whose run_data.input_guardrail_results is empty, losing guardrail context.
Useful? React with 👍 / 👎.
This pull request fixes a streaming-only guardrail race where
Runner.run_streamed()could still execute same-turn tool side effects after a parallel input guardrail tripwire had already been observed.The change keeps the released
run_in_parallel=Truecontract intact for still-running guardrails, but adds a narrow hardening checkpoint for the streaming path once a tripwire is already known. The streaming guardrail runner now records the first triggered result immediately, and streamed turn resolution checks for that state before executing tools or other same-turn side effects.This also adds regression coverage for the streaming-specific case while preserving the existing tests that document the broader parallel guardrail semantics.