Skip to content

Tweak on guardrail docstrings #1260

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

Merged
merged 3 commits into from
Jul 28, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/agents/guardrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ class InputGuardrail(Generic[TContext]):
You can use the `@input_guardrail()` decorator to turn a function into an `InputGuardrail`, or
create an `InputGuardrail` manually.

Guardrails return a `GuardrailResult`. If `result.tripwire_triggered` is `True`, the agent
execution will immediately stop and a `InputGuardrailTripwireTriggered` exception will be raised
Guardrails return a `GuardrailResult`. If `result.tripwire_triggered` is `True`,
the agent's execution will immediately stop, and
an `InputGuardrailTripwireTriggered` exception will be raised
"""

guardrail_function: Callable[
Expand Down Expand Up @@ -127,12 +128,12 @@ async def run(
@dataclass
class OutputGuardrail(Generic[TContext]):
"""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
They can be used to check if the output passes certain validation criteria

You can use the `@output_guardrail()` decorator to turn a function into an `OutputGuardrail`,
or create an `OutputGuardrail` manually.

Guardrails return a `GuardrailResult`. If `result.tripwire_triggered` is `True`, a
Guardrails return a `GuardrailResult`. If `result.tripwire_triggered` is `True`, an
`OutputGuardrailTripwireTriggered` exception will be raised.
"""

Expand Down Expand Up @@ -316,7 +317,7 @@ def decorator(
) -> OutputGuardrail[TContext_co]:
return OutputGuardrail(
guardrail_function=f,
# Guardrail name defaults to function name when not specified (None).
# Guardrail name defaults to function's name when not specified (None).
name=name if name else f.__name__,
)

Expand Down