Output guardrail check
Skill kjuhwa/skills-hub/skills/safety/output-guardrail-check
Validate or block agent output before returning it to the user using @output_guardrail.From its SKILL.md
npx -y skills add kjuhwa/skills-hub --skill output-guardrail-checkAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.5 KB, 427 tokens by cl100k_base, as published. Nobody here has run it
output-guardrail-check
Decorate a function with @output_guardrail and attach it to Agent.output_guardrails. If the guardrail detects a problem, tripwire_triggered=True raises OutputGuardrailTripwireTriggered.
When to apply
Preventing sensitive data leakage (PII, phone numbers, credentials) in agent replies, compliance filtering, or any post-generation validation.
Core snippet
from pydantic import BaseModel, Field
from agents import (
Agent, GuardrailFunctionOutput, OutputGuardrailTripwireTriggered,
RunContextWrapper, Runner, output_guardrail,
)
class MessageOutput(BaseModel):
reasoning: str = Field(description="Thoughts on how to respond")
response: str = Field(description="The response to the user")
user_name: str | None = Field(description="User name if known")
@output_guardrail
async def sensitive_data_check(
context: RunContextWrapper, agent: Agent, output: MessageOutput
) -> GuardrailFunctionOutput:
phone_number_in_response = "650" in output.response
return GuardrailFunctionOutput(
output_info={"phone_in_response": phone_number_in_response},
tripwire_triggered=phone_number_in_response,
)
agent = Agent(
name="Customer service",
instructions="You are a helpful customer service agent.",
output_type=MessageOutput,
output_guardrails=[sensitive_data_check],
)
async def main():
try:
result = await Runner.run(agent, "What is the support phone number?")
print(result.final_output)
except OutputGuardrailTripwireTriggered as e:
print(f"Output blocked: {e.output.output_info}")
Key notes
- Output guardrails run only for the last (final) agent in the chain
- Output guardrails always run after the agent completes (no parallel option)
outputparameter type must match the agent'soutput_typee.output.output_infocontains the diagnostic info set in the guardrail
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.