Ir para o conteúdo

wrapper

module wittgenstein_agent_guardrails.wrapper

GuardrailAgent — pre-check middleware wrapping a pydantic-ai Agent.

Classes

  • GuardrailAgent — Wraps a pydantic-ai Agent with a scope pre-check.

wittgenstein_agent_guardrails.wrapper.GuardrailAgent

dataclass GuardrailAgent(inner_agent: Any, scope_source: ScopeSource, refusal_message: str = DEFAULT_REFUSAL_MESSAGE)

Bases : Generic[DepsT]

Wraps a pydantic-ai Agent with a scope pre-check.

Blocks a call before it reaches the inner agent — and therefore before any LLM call happens — when scope_source.is_in_scope(user_prompt) is False. Cheaper and safer than only validating the answer after generation, since an out-of-scope request never reaches the model.

Methods

wittgenstein_agent_guardrails.wrapper.GuardrailAgent.run

async method GuardrailAgent.run(self, user_prompt: str, deps: DepsT, **kwargs: Any) → str