View a markdown version of this page

Screen streamed responses with guardrails - Amazon Bedrock AgentCore

Screen streamed responses with guardrails

When a model or an MCP server streams its response, Policy in AgentCore can screen the response while it streams. The gateway forwards the response to you in parts, after each part passes your output policies. You don’t have to wait for the complete response, and the gateway can still stop the response or mask sensitive information in it.

Terms used in this topic

This topic uses the following terms:

Guardrail check (check)

A guardrail in the condition of a policy that inspects text, such as BedrockGuardrails::SensitiveInformation(["EMAIL"], ["$.choices[*].message.content"]). For how to write one, see Writing guardrails in policies.

Finding

A piece of text that a check detects, such as an email address.

Data path

The part of the response that a check reads, such as $.choices[*].message.content for the answer text of a Chat Completions response. For more information, see Passing context to your guardrail.

Label

The text that replaces a masked finding, such as {EMAIL}.

Action

The operation of a gateway target that a policy applies to, such as ClaimsChat___POST:/v1/chat/completions.

Window

The amount of new text, 1,024 characters, after which the gateway evaluates a streamed response again.

Hold and release

The gateway holds the events of a streamed response that haven’t passed an evaluation yet. It releases them, which means that it forwards them to you, after an evaluation passes.

Output effects

Three effects act on what a target returns. Each effect acts when its guardrail condition is met. The following table shows what each effect does to an inference response. For an MCP tool response, each effect acts on the tool result, as described in How the gateway screens an MCP tool response.

Effect Streamed inference response Inference response that doesn’t stream

suppressOutput

The gateway holds the whole response until the response is complete, and then evaluates it once. You receive all of the response or an error.

You receive the response or an error.

interruptOutput

The gateway ends the response with an error event. You keep the parts that you already received.

You receive an error instead of the response.

redactOutput

The gateway masks each finding, such as an email address, and the response continues.

You receive the response with each finding masked.

interruptOutput and redactOutput screen a response while it streams: interruptOutput ends the response, and redactOutput masks the findings in it. To mask sensitive information in a request before the target receives it, use redactInput. For more information, see Mask sensitive information in requests. For more information about each effect, see Effects for guardrails.

Supported targets

interruptOutput and redactOutput support the following gateway target types:

Inference targets

Streamed responses of the following APIs:

  • OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages, for targets that use the bedrock-mantle (Amazon Bedrock Mantle endpoint), openai, or anthropic connector, and for inference provider targets.

  • Amazon Bedrock InvokeModelWithResponseStream, for targets that use the bedrock-runtime connector.

MCP targets

Tool responses that an MCP server streams as server-sent events (SSE).

HTTP targets

Not supported. For output policies on HTTP targets, use suppressOutput only.

Guardrail checks for each effect

interruptOutput can use any guardrail check that your policy engine offers, from Amazon Bedrock Guardrails or from a third-party provider. redactOutput and redactInput need a check that reports the location of each finding in the text, so that the gateway can mask it. The following table shows the checks that you can use with each effect.

Provider interruptOutput redactOutput and redactInput

Amazon Bedrock Guardrails (BedrockGuardrails)

All checks

BedrockGuardrails::SensitiveInformation

Check Point (CheckPoint)

All checks

CheckPoint::PII

Netskope (Netskope)

All checks

None

Prompt Security (PromptSecurity)

All checks

PromptSecurity::DataPrivacy::SensitiveData and PromptSecurity::DataPrivacy::Secrets

Rubrik (Rubrik)

All checks

None

Zscaler (Zscaler)

All checks

Zscaler::PII

suppressOutput and streamed responses

suppressOutput can use any check, and it works with streamed responses too. But it doesn’t screen a response while it streams. The gateway holds the whole stream and runs the check once, after the response is complete. To screen a response while it streams, use interruptOutput or redactOutput.

To use a third-party provider, register it on your policy engine first. For more information, see Register a third-party guardrail provider. For the checks and categories of each provider, see Third-party guardrail reference.

Choose the action for your policy

An output policy applies to the action of the operation that the gateway calls on the target. Each operation that a target serves is a separate action. The following list shows the action for each operation:

  • OpenAI Chat Completions: <target>___POST:/v1/chat/completions

  • OpenAI Responses: <target>___POST:/v1/responses

  • Anthropic Messages: <target>___POST:/v1/messages

  • Amazon Bedrock InvokeModelWithResponseStream: <target>___POST:/model/{model}/invoke-with-response-stream

  • Amazon Bedrock InvokeModel: <target>___POST:/model/{model}/invoke

  • An MCP tool: <target>___<tool name>

In the Amazon Bedrock actions, {model} is part of the action name. Write the literal text {model}, not a model ID.

A policy applies only to the actions that it names. A target can serve the same model through more than one operation, and each of these operations is a separate action. For example, a Bedrock Runtime target serves an Anthropic Claude model in the following two ways:

  • Through InvokeModelWithResponseStream, with the action <target>___POST:/model/{model}/invoke-with-response-stream

  • Through the Anthropic Messages API, with the action <target>___POST:/v1/messages

To screen the Claude responses of this target whichever API your clients call, write a policy for each of the two actions.

The gateway translates a request when the API that you call differs from the API that the target serves for the model. For example, you can call Chat Completions for an Anthropic Claude model that a Bedrock Runtime target serves through InvokeModelWithResponseStream. When the gateway translates your request, the target’s operation determines the action that your policy names and the format of the response that your data paths read.

The error event that ends an interrupted response uses the format of the API that you call. For more information about translated requests, see Use the Amazon Bedrock InvokeModel API with inference targets.

For example, suppose that you call Chat Completions for an Anthropic Claude model that a Bedrock Runtime target serves through InvokeModelWithResponseStream:

  • Write the policy for the target’s POST:/model/{model}/invoke-with-response-stream action.

  • The response is in the Anthropic Messages format. Read the text at $.content[*].text.

  • If the policy interrupts the response, you receive a Chat Completions error event.

In the opposite direction, suppose that you call InvokeModelWithResponseStream for an OpenAI gpt-oss model, and a Bedrock Mantle target serves the model through Chat Completions:

  • Write the policy for the target’s POST:/v1/chat/completions action.

  • The response is in the Chat Completions format. Read the text at $.choices[*].message.content. Each event that you receive contains a Chat Completions chunk.

  • If the policy interrupts the response, you receive a modelStreamErrorException event.

How the gateway screens an inference response

A streamed inference response arrives as many small events. Each event carries a few words of the answer.

Your policies don’t evaluate single events. Before each evaluation, the gateway combines all the events that it has received into one JSON document. The document has the same format as the response that the target returns when the response doesn’t stream. Your data paths read this document, so you write the same data paths whether or not the response streams.

The format of the document comes from the target’s operation, such as Chat Completions. For InvokeModelWithResponseStream, it also depends on the model. When an evaluation passes, the gateway forwards text to you. For when this happens, see When you receive the text.

For example, a Chat Completions stream sends its text in choices[].delta.content fragments. After the target sends the fragments –0— and –1—, the next evaluation sees the following document (some fields omitted):

{ "id": "chatcmpl-123", "object": "chat.completion", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Contact jane.doe@example.com" } } ] }

A check that reads $.choices[*].message.content sees the complete email address.

The gateway combines events into a complete document for the following formats:

  • OpenAI Chat Completions

  • OpenAI Responses

  • Anthropic Messages, including Anthropic Claude models on InvokeModelWithResponseStream

  • Amazon Nova models on InvokeModelWithResponseStream

For other models on InvokeModelWithResponseStream, each event carries part of the model’s response body. The text is in the same field as in a response that doesn’t stream, and the gateway joins the text of that field across events. For example, Meta Llama models send their text in the generation field, so a check that reads $.generation sees all the text received so far. For the paths of each model family, see Recommended data paths.

If the events don’t match the format of the operation, the gateway ends the response with the reason Output policy evaluation failed.

When you receive the text

The gateway evaluates a streamed inference response in windows of text. The window size is 1,024 characters for every guardrail check, including third-party checks. Each time the text at your data paths grows by one window, the gateway evaluates your policies again. Each evaluation covers all the text received so far.

When an evaluation passes, the gateway releases all text except the newest window. It keeps the newest window until the next evaluation also passes. A finding can cross the boundary between two windows. For example, an email address can start at the end of one window and end in the next. Because the gateway holds the newest window, it can still mask or stop a finding before any part of the finding reaches you.

The following table shows how a response with 3,500 characters of text reaches you. The gateway releases whole events, so the character counts are approximate.

Text received from the target Evaluation Text released to you

1,024 characters

First evaluation passes

None

2,048 characters

Second evaluation passes

Characters 1–1,024

3,072 characters

Third evaluation passes

Characters 1,025–2,048

3,500 characters (complete)

Final evaluation passes

Characters 2,049–3,500

As a result, you can expect the following:

  • A response with fewer than about 2,048 characters of text reaches you all at once, when the target finishes it.

  • A longer response starts to reach you after the target has sent about 2,048 characters. It then arrives in steps of about 1,024 characters. Each step consists of whole events, as the target sent them.

  • Events without text at your data paths, such as reasoning or tool calls, arrive with the text that follows them. For a reasoning model, the first text therefore arrives after the reasoning.

  • The HTTP status and headers reach you right away.

The gateway doesn’t send keep-alive events while it holds text. Set the read timeout of your client to allow for the delay.

A third-party check calls the provider at each evaluation. For how this affects the provider’s rate limits and pricing, see Streamed responses and request masking.

How the gateway screens an MCP tool response

An MCP server can stream a tool response as SSE. The stream carries messages such as progress notifications and ends with the tool result. The gateway screens the stream as follows:

  • Tool result or tool error. The gateway evaluates your output policies when the message arrives, and then forwards the message, masks it, or replaces it with an error.

  • Progress notifications, logging notifications, and server requests. These messages pass through as they arrive. Server requests include elicitation and sampling requests. Output policies don’t apply to these messages. If your MCP server can put sensitive information in these messages, remove it in the server before the server sends them.

While the gateway waits for the tool result, it sends SSE comment lines to keep the connection open. These are lines that start with :, and SSE clients ignore them.

A tool response that doesn’t stream is a single JSON message. The gateway evaluates it the same way as a tool result. You use the same data paths for both.

Recommended data paths

A data path tells a guardrail check which text of the response to read. Choose data paths for the text that you want to screen. In most cases, this is the answer that your users read.

How a data path reads a response

For output policies on inference targets, write each data path as a JSONPath, which starts with $. For MCP targets, you can also use a field path, as described in MCP targets. A JSONPath addresses the complete response, which is the JSON document that the target returns when the response doesn’t stream. You write the same path for a streamed response, because the gateway assembles the events into this document before each evaluation.

The data paths in this topic use the following JSONPath elements:

$

The root of the response.

.<field>

A field of an object, such as .content.

[*]

Every element of a list, such as every choice or every content block.

[?@.type=='message']

The elements of a list whose type field is message.

When a data path matches several values, the check reads them as one text, without separators between them. For example, $.content[*].text matches every text block of an Anthropic Messages response, and the check reads all the blocks together. A finding that spans two blocks is therefore still found. You can also give a check several data paths. For more information, see Passing context to your guardrail.

A check needs text to evaluate. If none of the data paths of a check find any text, the gateway denies the response. Keep the following in mind:

  • A data path that doesn’t match the response format denies every response. For example, $.content[*].text reads Anthropic Claude responses, but it doesn’t match Amazon Nova responses.

  • Reasoning text isn’t in every response. Some models send reasoning text only when you turn reasoning on. Put a reasoning path in the same check as the response-text path, not in a check of its own.

Inference targets

The following table shows the recommended data paths for each response format. The table has the following columns:

Response text

The answer that the model writes for your users.

Reasoning text

The text that a reasoning model writes before its answer, such as Anthropic Claude thinking. Some clients display this text. The response-text paths don’t read it. To screen reasoning text, add its path to the same check as the response-text path.

Format and models Response text Reasoning text

OpenAI Chat Completions (for example, OpenAI gpt-oss, DeepSeek, Mistral AI, and Qwen models on Amazon Bedrock Mantle)

$.choices[*].message.content

$.choices[*].message.reasoning

OpenAI Responses (for example, OpenAI GPT and gpt-oss models on Amazon Bedrock Mantle)

$.output[?@.type=='message'].content[*].text

$.output[?@.type=='reasoning'].content[*].text for gpt-oss models, and $.output[?@.type=='reasoning'].summary[*].text for OpenAI reasoning models

Anthropic Messages, and Anthropic Claude models on InvokeModelWithResponseStream

$.content[*].text

$.content[*].thinking

Amazon Nova models on InvokeModelWithResponseStream

$.output.message.content[*].text

—

Meta Llama models on InvokeModelWithResponseStream

$.generation

—

Mistral 7B, Mixtral 8x7B, and Mistral Large (24.02) on InvokeModelWithResponseStream

$.outputs[*].text

—

DeepSeek-R1 on InvokeModelWithResponseStream

$.choices[*].text, which also contains the model’s reasoning

—

For example, the following check screens both the answer and the thinking text of an Anthropic Claude response:

BedrockGuardrails::SensitiveInformation( ["EMAIL"], ["$.content[*].text", "$.content[*].thinking"] ).count() > 0
Masked thinking blocks

Anthropic Claude signs its thinking blocks. If you mask a thinking block and send it back to the model in a later turn, the model can reject the request.

MCP targets

An MCP tool result is a JSON-RPC 2.0 response, the message format that MCP uses. The text of the result is in the content list. A tool that declares an output schema can also return its data as an object in structuredContent, for example:

{ "jsonrpc": "2.0", "id": 7, "result": { "content": [{ "type": "text", "text": "{\"note\":\"Contact jane.doe@example.com today.\",\"ticketId\":\"T-1001\"}" }], "structuredContent": { "note": "Contact jane.doe@example.com today.", "ticketId": "T-1001" }, "isError": false } }

You can read a tool result with a field path or with a JSONPath. Both work the same way whether or not the tool response streams.

Field path

If the tool declares an output schema, a field path reads a field of the result by its name in the schema, such as context.output.note. For more information about field paths, see Passing context to your guardrail.

JSONPath

A JSONPath reads the JSON-RPC response of the tool call:

  • $.result.content[*].text reads the text content of the result.

  • $.result.structuredContent.<field> reads one field of the structured content, such as $.result.structuredContent.note.

The MCP specification recommends that a tool that returns structured content also returns the same data as text in content. To screen or mask both copies, put both paths in the same check:

BedrockGuardrails::SensitiveInformation( ["EMAIL"], ["$.result.content[*].text", "$.result.structuredContent.note"] ).count() > 0

Example: screen a support assistant’s streamed answers

This example walks through the policies for a claims support assistant, and shows what happens to its answers.

Scenario

The assistant calls a model through the ClaimsChat target of the gateway insurance-gw. The target uses the Amazon Bedrock Mantle endpoint and serves Chat Completions. The assistant streams the answers to its users, and you want the following:

  • Stop an answer as soon as it turns abusive. The part that the user already read is acceptable, but the rest isn’t.

  • Mask email addresses in answers. The rest of an answer is still useful, so the answer continues.

Policies

The following policies implement these requirements. Each part of the example explains one policy.

  1. Allow the action. Guardrail policies don’t authorize requests, so a permit policy makes the action reachable:

    permit( principal, action == AgentCore::Action::"ClaimsChat___POST:/v1/chat/completions", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/insurance-gw-a1b2c3d4e5" );
  2. Stop abusive answers. interruptOutput ends the answer and keeps what the user already received. The check reads the answer text at $.choices[*].message.content:

    interruptOutput( principal, action == AgentCore::Action::"ClaimsChat___POST:/v1/chat/completions", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/insurance-gw-a1b2c3d4e5" ) when guardrails { BedrockGuardrails::ContentFilter( ["INSULTS", "MISCONDUCT"], ["$.choices[*].message.content"] ).maxConfidenceScore().greaterThan(decimal("0.6")) };
  3. Mask email addresses. redactOutput replaces each email address with {EMAIL} and lets the answer continue:

    redactOutput( principal, action == AgentCore::Action::"ClaimsChat___POST:/v1/chat/completions", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/insurance-gw-a1b2c3d4e5" ) when guardrails { BedrockGuardrails::SensitiveInformation(["EMAIL"], ["$.choices[*].message.content"]).count() > 0 };

Don’t add a suppressOutput policy to this action. It makes the gateway hold every answer until the answer is complete, and the redactOutput policy then denies any answer that contains an email address instead of masking it.

What happens to an answer

Suppose that the model writes an answer of about 3,000 characters, and the answer contains an email address at about character 2,500. The gateway evaluates both output policies at each step:

Text received Evaluation What the user receives

1,024 characters

Both policies pass.

Nothing yet. The gateway holds the newest window.

2,048 characters

Both policies pass.

Characters 1–1,024.

3,000 characters (complete)

The redactOutput policy finds the email address. The interruptOutput policy passes.

Characters 1,025–3,000, with the email address replaced by {EMAIL}.

Now suppose that the answer turns abusive at about character 1,500 instead. The evaluation at 2,048 characters denies the answer. The gateway ends the stream with an error event. The user received nothing from this answer, because the gateway hadn’t released any text yet. For the error event, see What you receive when a response is interrupted.

Use a third-party provider

You can use the checks of a third-party provider in the same way. For example, in a Region without Amazon Bedrock Guardrails, the following policy masks email addresses with the Zscaler PII check. The label is the category that the policy names, so you receive {EMAIL_ADDRESS}:

redactOutput( principal, action == AgentCore::Action::"ClaimsChat___POST:/v1/chat/completions", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/insurance-gw-a1b2c3d4e5" ) when guardrails { Zscaler::PII(["EMAIL_ADDRESS"], ["$.choices[*].message.content"]).count() > 0 };

To stop an answer instead of masking it, use the same check with interruptOutput. Before you use a third-party check, register the provider on your policy engine. For more information, see Register a third-party guardrail provider. For the checks that each provider offers for each effect, see Guardrail checks for each effect.

More examples

The following examples show policies for other formats and for MCP tools.

Mask email addresses in an Anthropic Messages response
redactOutput( principal, action == AgentCore::Action::"ClaimsMessages___POST:/v1/messages", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/insurance-gw-a1b2c3d4e5" ) when guardrails { BedrockGuardrails::SensitiveInformation(["EMAIL"], ["$.content[*].text"]).count() > 0 };
Stop a Meta Llama answer on InvokeModelWithResponseStream that contains a US Social Security number
interruptOutput( principal, action == AgentCore::Action::"ClaimsBedrock___POST:/model/{model}/invoke-with-response-stream", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/insurance-gw-a1b2c3d4e5" ) when guardrails { BedrockGuardrails::SensitiveInformation(["US_SOCIAL_SECURITY_NUMBER"], ["$.generation"]).count() > 0 };
Mask email addresses in an MCP tool result
redactOutput( principal, action == AgentCore::Action::"CustomerTools___lookup_customer", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/insurance-gw-a1b2c3d4e5" ) when guardrails { BedrockGuardrails::SensitiveInformation(["EMAIL"], ["$.result.content[*].text"]).count() > 0 };

The tool result reaches you with each email address replaced by {EMAIL}, whether or not the tool response streams.

For more examples, see Screen streamed responses.

What you receive when a response is interrupted

When an interruptOutput policy denies a streamed response, the gateway stops forwarding the response. You keep the parts that you already received, and one error event ends the stream. Because the response has already started, its HTTP status is 200. This is true even when the first evaluation denies the response and you receive no text.

The error message has the form Output blocked by policy: <reason>. The reason is one of the following:

  • Policy evaluation denied due to <policy IDs> when a policy denies the response.

  • Authorization denied: request missing field(s) required for guardrail evaluation: <path>. when a check finds no text at its data paths. For more information, see How a data path reads a response.

  • Output policy evaluation failed when the gateway can’t evaluate the response. For example, a guardrail check or a third-party provider fails, or the events don’t follow the format of the operation. For more information, see When a guardrail check fails.

The error event uses the format of the API that you call:

OpenAI Chat Completions and OpenAI Responses

An SSE event named error:

event: error data: {"error":{"message":"Output blocked by policy: Policy evaluation denied due to <policy-id>","type":"permission_error","code":"403"}}
Anthropic Messages

An SSE event named error, in the Anthropic error format. The order of the JSON keys can vary.

event: error data: {"type":"error","error":{"type":"permission_error","message":"Output blocked by policy: Policy evaluation denied due to <policy-id>"}}
Amazon Bedrock InvokeModelWithResponseStream

A modelStreamErrorException event with the message Output blocked by policy: <reason>. The AWS SDK for Python (Boto3) raises an EventStreamError.

MCP tool responses over SSE

A JSON-RPC error for the tool call, in place of the tool result. The error code is -32002, or -20001 when the client negotiated MCP protocol version 2026-07-28.

{"jsonrpc":"2.0","id":7,"error":{"code":-32002,"message":"Output blocked by policy: Policy evaluation denied due to <policy-id>"}}

When a policy denies a response that the gateway holds, you receive an error instead of the response. The gateway holds a response that doesn’t stream, and a streamed response when a suppressOutput policy applies to the action. The error depends on the API that you call:

  • OpenAI APIs return HTTP status 403 with the body {"error":{"message":"Output blocked by policy: <reason>","type":"permission_error","code":"403"}}.

  • Anthropic Messages returns HTTP status 403 with the body {"type":"error","error":{"type":"permission_error","message":"Output blocked by policy: <reason>"}}.

  • Amazon Bedrock operations return HTTP status 403 with the body {"message":"Output blocked by policy: <reason>"}. The AWS SDKs raise an AccessDeniedException.

  • MCP tool responses end with the JSON-RPC error in place of the tool result. A tool response that doesn’t stream returns HTTP status 403. A tool response that streams over SSE keeps HTTP status 200, and its notifications still pass through as they arrive.

What you receive when content is masked

A redactOutput policy replaces each finding with a label in braces, and the response continues. The label depends on the check:

  • For an Amazon Bedrock Guardrails sensitive information check, the label is the entity type, such as {EMAIL} or {US_SOCIAL_SECURITY_NUMBER}.

  • For a third-party check, the label is the category that the policy names, such as {EMAIL_ADDRESS}.

A target can send a finding across several events. The gateway then puts the label in the event where the finding starts, and removes the rest of the finding from the events that follow. For example, a target sends the following Chat Completions events (some fields omitted):

data: {"choices":[{"index":0,"delta":{"content":"Contact jane."}}]} data: {"choices":[{"index":0,"delta":{"content":"doe@example.com today."}}]}

You receive the following events:

data: {"choices":[{"index":0,"delta":{"content":"Contact {EMAIL}"}}]} data: {"choices":[{"index":0,"delta":{"content":" today."}}]}

The check reads only the text at its data paths. Text at other locations, such as reasoning text, isn’t screened. To screen and mask that text too, add its data path to the check.

Keep the following in mind when you process a masked response:

  • The gateway masks JSON values, never JSON keys.

  • The gateway rewrites each event that it masks as compact JSON. Apart from the labels, the event has the same content as the target sent, but its formatting changes. The gateway removes the whitespace between JSON elements and writes 0.10 as 0.1. All other events reach you as the target sent them.

  • The gateway doesn’t update headers such as ETag or Digest. Don’t use these headers to check the content of a masked response.

  • The gateway never releases a finding unmasked. If it can’t mask a finding, it denies the response, as an interruptOutput policy does.

Combine output effects on an action

The output policies on an action, including LOG_ONLY policies, determine how you receive a streamed inference response, as follows:

Only interruptOutput and redactOutput policies

The gateway screens the response while it streams. You receive the text in steps.

At least one suppressOutput policy

The gateway holds the whole response and evaluates it once. A redactOutput policy on the action denies the response instead of masking it.

No output policies

You receive the response as the target sends it.

To keep masking on an action, don’t combine redactOutput with suppressOutput on that action.

Test interrupt and redact policies in LOG_ONLY mode

An interruptOutput or redactOutput policy in LOG_ONLY mode never ends or masks a response. The gateway evaluates the policy at the same points in the stream as an active policy, and reports the results in traces and metrics. For the metrics, see AgentCore generated policy observability data. For more information about testing, see Test a policy in LOG_ONLY mode.

A LOG_ONLY policy can still change how you receive a response, in the following ways:

  • A LOG_ONLY interruptOutput or redactOutput policy makes the gateway screen the response while it streams. You receive the text in steps, as described in When you receive the text.

  • A LOG_ONLY suppressOutput policy makes the gateway hold the whole response. An active redactOutput policy on the same action then denies the response instead of masking it.

Rules for interrupt and redact policies

interruptOutput and redactOutput follow the same rules as suppressOutput: the condition consists only of guardrail checks, and the policy names its actions and its gateway. For these rules, see Limitations. A redactOutput check must read the response, name at least one category, and have at least one data path. The following rules also apply.

Name the actions

When you create or update a policy that doesn’t name its actions, Policy in AgentCore rejects it with an error like the following:

A interruptOutput policy must specify the actions it applies to, for example `action == AgentCore::Action::"<target>___<action>"`; it applies only to the actions of inference and MCP targets.
Name actions of inference and MCP targets

If you create a policy for an action of an HTTP target, the policy status becomes CREATE_FAILED, with a status reason like the following:

Gateway target 'my-runtime-target' is an HTTP target; a redactOutput policy applies only to the actions of inference and MCP targets.
Use a check that reports where it finds content

For redactOutput, use a check from the redactOutput column of Guardrail checks for each effect. If you use another check, Policy in AgentCore rejects the policy with an error like the following:

redactOutput is not supported for the guardrails capability 'BedrockGuardrails::ContentFilter' mentioned in the policy.

For the checks of each third-party provider, see Third-party guardrail reference. Profile checks (<Namespace>::Custom) return only whether the provider allows the content, so you can use them with interruptOutput but not to mask content.

Limits

When the gateway screens a response, the following limits apply. If a response exceeds a limit, the gateway ends the response with the reason Output policy evaluation failed.

  • Each SSE event of a streamed response can be at most 10 MiB.

  • Each event of an InvokeModelWithResponseStream response can be at most 24 MiB.

  • The body of a response that doesn’t stream can be at most 10 MiB.

  • The gateway holds at most 200,000 events or 100 MiB of events of a streamed response at a time.