From ff334d642a87a5a45cb8df4705aabf0f221477f8 Mon Sep 17 00:00:00 2001 From: MUHAMMAD SALMAN HUSSAIN <160324527+mshsheikh@users.noreply.github.com> Date: Wed, 16 Jul 2025 15:26:57 +0500 Subject: [PATCH 1/3] docs: clarify GuardrailFunctionOutput docstrings This update refines the inline documentation for the `GuardrailFunctionOutput` class by rewording the `output_info` and `tripwire_triggered` docstrings to be more concise and precise. No code behavior or public API signatures have changed. --- src/agents/guardrail.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/agents/guardrail.py b/src/agents/guardrail.py index 2bb0f014e..594d19ebb 100644 --- a/src/agents/guardrail.py +++ b/src/agents/guardrail.py @@ -22,13 +22,12 @@ class GuardrailFunctionOutput: output_info: Any """ - Optional information about the guardrail's output. For example, the guardrail could include - information about the checks it performed and granular results. + Optional metadata about the guardrail's execution, such as details of checks performed or results. """ tripwire_triggered: bool """ - Whether the tripwire was triggered. If triggered, the agent's execution will be halted. + Whether the tripwire was triggered; if True, agent execution will halt. """ From 2819e64308fc8ba214553795d2959e6686c01d57 Mon Sep 17 00:00:00 2001 From: MUHAMMAD SALMAN HUSSAIN <160324527+mshsheikh@users.noreply.github.com> Date: Wed, 16 Jul 2025 15:43:32 +0500 Subject: [PATCH 2/3] docs: clarify GuardrailFunctionOutput docstrings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This update refines the inline documentation for the `GuardrailFunctionOutput` class by rewording the `output_info` and `tripwire_triggered` docstrings to be more concise and precise. ✓ No code behavior or public API signatures have changed. ✓ This is purely a documentation enhancement to improve clarity for future maintainers and users. --- src/agents/guardrail.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/agents/guardrail.py b/src/agents/guardrail.py index 594d19ebb..5fc36e4ca 100644 --- a/src/agents/guardrail.py +++ b/src/agents/guardrail.py @@ -41,7 +41,9 @@ class InputGuardrailResult: """ output: GuardrailFunctionOutput - """The output of the guardrail function.""" + """ + The output of the guardrail function. + """ @dataclass From 503e152df4842e0f4dfc07697dc71d3ba66bff1f Mon Sep 17 00:00:00 2001 From: MUHAMMAD SALMAN HUSSAIN <160324527+mshsheikh@users.noreply.github.com> Date: Wed, 16 Jul 2025 16:07:13 +0500 Subject: [PATCH 3/3] docs: clarify GuardrailFunctionOutput docstrings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This update refines the inline documentation for the `GuardrailFunctionOutput` class by rewording the `output_info` and `tripwire_triggered` docstrings to be more concise and precise. ✓ No code behavior or public API signatures have changed. ✓ This is purely a documentation enhancement to improve clarity for future maintainers and users. --- src/agents/guardrail.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/agents/guardrail.py b/src/agents/guardrail.py index 5fc36e4ca..ef22613f4 100644 --- a/src/agents/guardrail.py +++ b/src/agents/guardrail.py @@ -1,3 +1,4 @@ + from __future__ import annotations import inspect @@ -66,12 +67,15 @@ class OutputGuardrailResult: """ output: GuardrailFunctionOutput - """The output of the guardrail function.""" + """ + The output of the guardrail function. + """ @dataclass class InputGuardrail(Generic[TContext]): - """Input guardrails are checks that run in parallel to the agent's execution. + """ + Input guardrails are checks that run in parallel to the agent's execution. They can be used to do things like: - Check if input messages are off-topic - Take over control of the agent's execution if an unexpected input is detected @@ -87,13 +91,13 @@ class InputGuardrail(Generic[TContext]): [RunContextWrapper[TContext], Agent[Any], str | list[TResponseInputItem]], MaybeAwaitable[GuardrailFunctionOutput], ] - """A function that receives the agent input and the context, and returns a - `GuardrailResult`. The result marks whether the tripwire was triggered, and can optionally - include information about the guardrail's output. + """ + A function that receives the agent input and the context, and returns a `GuardrailResult`. The result marks whether the tripwire was triggered, and can optionally, include information about the guardrail's output. """ name: str | None = None - """The name of the guardrail, used for tracing. If not provided, we'll use the guardrail + """ + The name of the guardrail, used for tracing. If not provided, we'll use the guardrail function's name. """ @@ -127,7 +131,8 @@ async def run( @dataclass class OutputGuardrail(Generic[TContext]): - """Output guardrails are checks that run on the final output of an agent. + """ + Output guardrails are checks that run on the final output of an agent. They can be used to do check if the output passes certain validation criteria You can use the `@output_guardrail()` decorator to turn a function into an `OutputGuardrail`, @@ -141,14 +146,13 @@ class OutputGuardrail(Generic[TContext]): [RunContextWrapper[TContext], Agent[Any], Any], MaybeAwaitable[GuardrailFunctionOutput], ] - """A function that receives the final agent, its output, and the context, and returns a - `GuardrailResult`. The result marks whether the tripwire was triggered, and can optionally - include information about the guardrail's output. + """ + A function that receives the final agent, its output, and the context, and returns a `GuardrailResult`. The result marks whether the tripwire was triggered, and can optionally, include information about the guardrail's output. """ name: str | None = None - """The name of the guardrail, used for tracing. If not provided, we'll use the guardrail - function's name. + """ + The name of the guardrail, used for tracing. If not provided, we'll use the guardrail function's name. """ def get_name(self) -> str: