Skip to content

[NEW CONTENT] Bedrock guardrail_latest_message #554

@Unshure

Description

@Unshure

Proposed Content

Update the bedrock model page to cover the guardrail_latest_message parameter added in this commit: strands-agents/sdk-python@08bf563

Location

https://strandsagents.com/latest/documentation/docs/user-guide/concepts/model-providers/amazon-bedrock/

Rationale

Missing functionality

Content Outline (Optional)

No response

References

No response


Implementation Requirements

Based on analysis of the referenced commit and existing documentation structure.

New Parameter Details

Parameter Type Default Description
guardrail_latest_message Optional[bool] False When enabled, sends only the latest user message to guardrails instead of the entire conversation

Technical Behavior

When guardrail_latest_message=True:

  • Only the last user message is evaluated by guardrails
  • Text content is wrapped as: {"guardContent": {"text": {"text": "message"}}}
  • Image content is wrapped as: {"guardContent": {"image": {...}}}
  • Earlier messages in the conversation are not evaluated by guardrails

Use Cases

This parameter is useful when:

  • Performance optimization: Evaluate less content per request
  • Cost reduction: Fewer tokens processed by guardrails
  • Targeted checking: Only evaluate the newest user input, trusting that previous messages have already been validated

Files to Modify

  1. docs/user-guide/concepts/model-providers/amazon-bedrock.md
    • Add guardrail_latest_message parameter to the Guardrails section (around line 421-431)
    • Include the parameter in the existing code example with a brief comment explaining its purpose

Documentation Changes

Update the existing Guardrails code example in amazon-bedrock.md to include the new parameter:

# Using guardrails with BedrockModel
bedrock_model = BedrockModel(
    model_id="anthropic.claude-sonnet-4-20250514-v1:0",
    guardrail_id="your-guardrail-id",
    guardrail_version="DRAFT",
    guardrail_trace="enabled",  # Options: "enabled", "disabled", "enabled_full"
    guardrail_stream_processing_mode="sync",  # Options: "sync", "async"
    guardrail_redact_input=True,  # Default: True
    guardrail_redact_input_message="Blocked Input!",
    guardrail_redact_output=False,  # Default: False
    guardrail_redact_output_message="Blocked Output!",
    guardrail_latest_message=True,  # Only evaluate the latest user message (default: False)
)

Add a brief explanation below the code block:

Note: When guardrail_latest_message=True, only the most recent user message is sent to guardrails for evaluation. This can improve performance and reduce costs in multi-turn conversations where earlier messages have already been validated.

Acceptance Criteria

  • guardrail_latest_message parameter is documented in the Guardrails section of amazon-bedrock.md
  • Code example includes the new parameter with a descriptive comment
  • Brief explanation of when/why to use this parameter is included
  • Documentation builds successfully with mkdocs build
  • Parameter name and behavior matches the SDK implementation

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions