Skip to content

API Reference parrot.bots.guardrails.builtin.secrets

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.bots.guardrails.builtin.secrets

View source

SecretsGuardrail — wraps OutputScrubber (FEAT-252) as a guardrail.

Encapsulates the existing secret/PII-adjacent redaction engine (parrot.security.redaction.OutputScrubber) as a pluggable TOOL_OUTPUT/ OUTPUT Guardrail, so it can be ordered, combined with future guardrails (PII, groundedness, moderation), and driven by the unified guardrails=[...]/enable_redaction config surface instead of being called ad hoc at four separate seams. See sdd/specs/guardrails-infrastructure.spec.md §3 Module 3 (FEAT-396).

Note on scrub(): OutputScrubber.scrub(value: Any) -> Any natively handles str/dict/list/tuple (recursive structure traversal) — a wider contract than Guardrail.check(content: str, ...) -> GuardrailResult (whose content/GuardrailResult.content are Pydantic-typed as str). Callers with non-string payloads that still need OutputScrubber's native Any-typed traversal (e.g. the FEAT-252 tool hook's ToolResult.result/ .metadata fields, which are frequently dict/list) use scrub() directly rather than the string-only check()/pipeline path — see tools/abstract.py's _default_secrets_guardrail().

Alias Guardrail

Re-exported from parrot.bots.guardrails.base.Guardrail.

Alias GuardrailAction

Re-exported from parrot.bots.guardrails.base.GuardrailAction.

Alias GuardrailContext

Re-exported from parrot.bots.guardrails.base.GuardrailContext.

Alias GuardrailResult

Re-exported from parrot.bots.guardrails.base.GuardrailResult.

Alias GuardrailStage

Re-exported from parrot.bots.guardrails.base.GuardrailStage.

Alias OutputScrubber

Re-exported from parrot.security.redaction.OutputScrubber.

Alias ScrubPolicy

Re-exported from parrot.security.redaction.ScrubPolicy.

Class SecretsGuardrail

TOOL_OUTPUT/OUTPUT guardrail wrapping OutputScrubber.

Always runs first within its stages (priority 10, sanitizer band) — other transformers (e.g. a future PII guardrail) must never scan already-***REDACTED*** text.

Parameter Type Default Description
policy ScrubPolicy | None None Scrub policy forwarded to OutputScrubber. Defaults to ScrubPolicy().
tool_name str 'unknown' Default audit-log tool-name hint, overridable per call.
**kwargs Any {} Accepted and ignored, for forward-compat with extra policy keys passed via guardrails=[{"name": ..., ...}].

Attributes:

Attribute Type Description
stages set
policy The ScrubPolicy forwarded to the wrapped OutputScrubber.

Method SecretsGuardrail.scrub

Recursively scrub any value (str/dict/list/tuple), as-is from FEAT-252.

Direct, Any-typed escape hatch for callers that cannot express their payload as Guardrail.check(content: str, ...) — see module docstring. Not part of the Guardrail ABC.

scrub(value: Any, tool_name: str | None = None) -> Any

Parameter Type Default Description
value Any The value to scrub.
tool_name str | None None Overrides the instance-level tool-name audit hint.

Returns: Any — A sanitized copy of value.

Method SecretsGuardrail.check

Scrub string content for the standard Guardrail/Pipeline flow.

check(content: str, ctx: GuardrailContext) -> GuardrailResult

Parameter Type Default Description
content str The text content to scrub.
ctx GuardrailContext Call context. ctx.tool_name (TOOL_OUTPUT) is used as the audit-log tool-name hint when present.

Returns: GuardrailResult — PASS if nothing changed (including already-scrubbed content, per idempotency); otherwise TRANSFORM with the scrubbed text.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally