Skip to content

[CORRECTION] Example for guardrails in documentation needs updated model ID #310

@morganwillisaws

Description

@morganwillisaws

Documentation Location

https://strandsagents.com/latest/documentation/docs/user-guide/safety-security/guardrails/?h=guardrails

Current Content

The sample included in the documentation for using Amazon Bedrock Guardrails throws a validation exception for the amazon bedrock model ID. Additionally, Claude Sonnet 3.5 v2 is considered legacy. Claude Sonnet 3.5 doesn't support on-demand inference.

Error thrown: botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the ConverseStream operation: Invocation of model ID anthropic.claude-3-5-sonnet-20241022-v2:0 with on-demand throughput isn’t supported. Retry your request with the ID or ARN of an inference profile that contains this model.

Correction Needed

This should be updated to point to an inference profile ID for a newer model instead of a direct model ID. I recommend changing it to global.anthropic.claude-sonnet-4-5-20250929-v1:0 and it works.

Supporting Evidence

This can be verified by updating the code to use a newer model with an inference profile as shown here:

import json
from strands import Agent
from strands.models import BedrockModel

# Create a Bedrock model with guardrail configuration
bedrock_model = BedrockModel(
    model_id="global.anthropic.claude-sonnet-4-5-20250929-v1:0",
    guardrail_id="du0p3suv4cl6",         # Your Bedrock guardrail ID
    guardrail_version="1",                    # Guardrail version
    guardrail_trace="enabled",                # Enable trace info for debugging
)

# Create agent with the guardrail-protected model
agent = Agent(
    system_prompt="You are a helpful assistant.",
    model=bedrock_model,
)

# Use the protected agent for conversations
response = agent("tell me how to kill people")

# Handle potential guardrail interventions
if response.stop_reason == "guardrail_intervened":
    print("Content was blocked by guardrails, conversation context overwritten!")

print(f"Conversation: {json.dumps(agent.messages, indent=4)}")

There is an accepted answer on re:Post explaining this error and how to fix it: https://repost.aws/questions/QUEU82wbYVQk2oU4eNwyiong/bedrock-api-invocation-error-on-demand-throughput-isn-s-supported

Additionally, here is the documentation for the supported inference profile IDs for Claude: https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html

Here you can also see that Claude Sonnet 3.5 is EOL March 1, 2026: https://docs.aws.amazon.com/bedrock/latest/userguide/model-lifecycle.html

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions