Skip to content

strands.types.guardrails

Guardrail-related type definitions for the SDK.

These types are modeled after the Bedrock API.

class GuardrailConfig(TypedDict)

Defined in: src/strands/types/guardrails.py:13

Configuration for content filtering guardrails.

Attributes:

  • guardrailIdentifier - Unique identifier for the guardrail.
  • guardrailVersion - Version of the guardrail to apply.
  • streamProcessingMode - Processing mode.
  • trace - The trace behavior for the guardrail.
class Topic(TypedDict)

Defined in: src/strands/types/guardrails.py:29

Information about a topic guardrail.

Attributes:

  • action - The action the guardrail should take when it intervenes on a topic.
  • name - The name for the guardrail.
  • type - The type behavior that the guardrail should perform when the model detects the topic.
class TopicPolicy(TypedDict)

Defined in: src/strands/types/guardrails.py:43

A behavior assessment of a topic policy.

Attributes:

  • topics - The topics in the assessment.
class ContentFilter(TypedDict)

Defined in: src/strands/types/guardrails.py:53

The content filter for a guardrail.

Attributes:

  • action - Action to take when content is detected.
  • confidence - Confidence level of the detection.
  • type - The type of content to filter.
class ContentPolicy(TypedDict)

Defined in: src/strands/types/guardrails.py:67

An assessment of a content policy for a guardrail.

Attributes:

  • filters - List of content filters to apply.
class CustomWord(TypedDict)

Defined in: src/strands/types/guardrails.py:77

Definition of a custom word to be filtered.

Attributes:

  • action - Action to take when the word is detected.
  • match - The word or phrase to match.
class ManagedWord(TypedDict)

Defined in: src/strands/types/guardrails.py:89

Definition of a managed word to be filtered.

Attributes:

  • action - Action to take when the word is detected.
  • match - The word or phrase to match.
  • type - Type of the word.
class WordPolicy(TypedDict)

Defined in: src/strands/types/guardrails.py:103

The word policy assessment.

Attributes:

  • customWords - List of custom words to filter.
  • managedWordLists - List of managed word lists to filter.
class PIIEntity(TypedDict)

Defined in: src/strands/types/guardrails.py:115

Definition of a Personally Identifiable Information (PII) entity to be filtered.

Attributes:

  • action - Action to take when PII is detected.
  • match - The specific PII instance to match.
  • type - The type of PII to detect.
class Regex(TypedDict)

Defined in: src/strands/types/guardrails.py:161

Definition of a custom regex pattern for filtering sensitive information.

Attributes:

  • action - Action to take when the pattern is matched.
  • match - The regex filter match.
  • name - Name of the regex pattern for identification.
  • regex - The regex query.
class SensitiveInformationPolicy(TypedDict)

Defined in: src/strands/types/guardrails.py:177

Policy defining sensitive information filtering rules.

Attributes:

  • piiEntities - List of Personally Identifiable Information (PII) entities to detect and handle.
  • regexes - The regex queries in the assessment.
class ContextualGroundingFilter(TypedDict)

Defined in: src/strands/types/guardrails.py:189

Filter for ensuring responses are grounded in provided context.

Attributes:

  • action - Action to take when the threshold is not met.
  • score - The score generated by contextual grounding filter (range [0, 1]).
  • threshold - Threshold used by contextual grounding filter to determine whether the content is grounded or not.
  • type - The contextual grounding filter type.
class ContextualGroundingPolicy(TypedDict)

Defined in: src/strands/types/guardrails.py:205

The policy assessment details for the guardrails contextual grounding filter.

Attributes:

  • filters - The filter details for the guardrails contextual grounding filter.
class GuardrailAssessment(TypedDict)

Defined in: src/strands/types/guardrails.py:215

A behavior assessment of the guardrail policies used in a call to the Converse API.

Attributes:

  • contentPolicy - The content policy.
  • contextualGroundingPolicy - The contextual grounding policy used for the guardrail assessment.
  • sensitiveInformationPolicy - The sensitive information policy.
  • topicPolicy - The topic policy.
  • wordPolicy - The word policy.
class GuardrailTrace(TypedDict)

Defined in: src/strands/types/guardrails.py:233

Trace information from guardrail processing.

Attributes:

  • inputAssessment - Assessment of input content against guardrail policies, keyed by input identifier.
  • modelOutput - The original output from the model before guardrail processing.
  • outputAssessments - Assessments of output content against guardrail policies, keyed by output identifier.
class Trace(TypedDict)

Defined in: src/strands/types/guardrails.py:247

A Top level guardrail trace object.

Attributes:

  • guardrail - Trace information from guardrail processing.