diff --git a/src/agents/guardrail.py b/src/agents/guardrail.py index a96f0f7d7..f8a272b53 100644 --- a/src/agents/guardrail.py +++ b/src/agents/guardrail.py @@ -241,7 +241,11 @@ async def my_async_guardrail(...): ... def decorator( f: _InputGuardrailFuncSync[TContext_co] | _InputGuardrailFuncAsync[TContext_co], ) -> InputGuardrail[TContext_co]: - return InputGuardrail(guardrail_function=f, name=name) + return InputGuardrail( + guardrail_function=f, + # If not set, guardrail name uses the function’s name by default. + name=name if name else f.__name__ + ) if func is not None: # Decorator was used without parentheses