agentsclimarketplace

Input guardrail agent

Skill kjuhwa/skills-hub/skills/safety/input-guardrail-agent

Block off-topic or policy-violating user input before the main agent runs using @input_guardrail.From its SKILL.md

Install
npx -y skills add kjuhwa/skills-hub --skill input-guardrail-agent

Assembled 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.7 KB, 493 tokens by cl100k_base, as published. Nobody here has run it

input-guardrail-agent

Decorate a function with @input_guardrail and attach it to an agent's input_guardrails list. If the guardrail's tripwire_triggered=True, an InputGuardrailTripwireTriggered exception is raised and the main agent never runs.

When to apply

Cost-control (block expensive model before it runs), content moderation (off-topic check), or compliance (detect PII/malicious input). Run fast/cheap checks before the expensive main agent.

Core snippet

from pydantic import BaseModel
from agents import (
    Agent, GuardrailFunctionOutput, InputGuardrailTripwireTriggered,
    RunContextWrapper, Runner, TResponseInputItem, input_guardrail,
)

class MathHomeworkOutput(BaseModel):
    reasoning: str
    is_math_homework: bool

guardrail_agent = Agent(
    name="Guardrail check",
    instructions="Check if the user is asking you to do their math homework.",
    output_type=MathHomeworkOutput,
)

@input_guardrail
async def math_guardrail(
    context: RunContextWrapper[None], agent: Agent, input: str | list[TResponseInputItem]
) -> GuardrailFunctionOutput:
    result = await Runner.run(guardrail_agent, input, context=context.context)
    final_output = result.final_output_as(MathHomeworkOutput)
    return GuardrailFunctionOutput(
        output_info=final_output,
        tripwire_triggered=final_output.is_math_homework,
    )

main_agent = Agent(
    name="Customer support agent",
    instructions="You are a customer support agent.",
    input_guardrails=[math_guardrail],
)

async def main():
    try:
        result = await Runner.run(main_agent, "Can you help me solve 2+2?")
        print(result.final_output)
    except InputGuardrailTripwireTriggered:
        print("Guardrail triggered! This looks like math homework.")

Key notes

  • Input guardrails run only when the agent is the first agent in the chain
  • Default mode: runs in parallel with the agent for best latency
  • For blocking mode (agent never starts if guardrail fails): @input_guardrail(run_in_parallel=False)
  • The guardrail function can be async or sync
  • output_info is stored in the exception for downstream handling

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,144. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.