fix(aws): Raise error on unsupported guardrail header usage with Mantle - #1225
Merged
Michael Chin (michaelnchin) merged 2 commits intoAug 25, 2026
Conversation
Michael Chin (michaelnchin)
left a comment
Collaborator
Author
There was a problem hiding this comment.
Michael Chin (michaelnchin)
left a comment
Collaborator
Author
There was a problem hiding this comment.
Passing after fix merge: https://github.com/langchain-ai/langchain-aws/actions/runs/32794908648
Michael Chin (michaelnchin)
merged commit Aug 25, 2026
6ae3f6e
into
langchain-ai:main
15 checks passed
Michael Chin (michaelnchin)
deleted the
fix/mantle-guardrails-validation
branch
August 25, 2026 00:54
Rishabh Agrawal (rishabhagrawal1)
added a commit
to rishabhagrawal1/langchain-aws
that referenced
this pull request
Sep 1, 2026
Add ChatOpenAIBedrock, targeting the OpenAI-compatible Chat Completions
and Responses APIs on the bedrock-runtime endpoint
(bedrock-runtime.{region}.amazonaws.com/openai/v1). This is the
recommended endpoint for OpenAI models (e.g. GPT-5.x) on Amazon Bedrock
and supports cross-Region inference via geographic/global inference
profile ids passed as the model
(https://docs.aws.amazon.com/bedrock/latest/userguide/endpoints.html).
Refactor the shared logic out of ChatOpenAIMantle into a private
_BaseChatBedrockOpenAI base so both endpoints share region/base-URL
resolution, Bedrock API-key auth (static bearer token or short-term keys
derived from AWS credentials, following langchain-ai#1203), profile resolution,
LangSmith tracing metadata, and the Chat Completions/Responses routing.
Each public class only sets endpoint-specific class attributes;
ChatOpenAIMantle's public surface is unchanged. The base rejects direct
instantiation with a clear error.
Extract the shared cross-Region prefix stripping and guardrail-rejection
guard into langchain_aws.utils helpers, and route ChatBedrockConverse and
ChatAnthropicMantle through them, removing the duplicated copies (the
guard was previously duplicated per langchain-ai#1225). Behavior is unchanged.
Resolve capability profiles through any cross-Region prefix, so a
geographic id such as us.openai.gpt-5.6-sol reuses the base
openai.gpt-5.6-sol capability profile (mirroring ChatBedrockConverse).
Guardrails are rejected on the OpenAI-compatible path for both endpoints:
bedrock-mantle silently ignores them, and no OpenAI model on
bedrock-runtime accepts them yet.
Rishabh Agrawal (rishabhagrawal1)
added a commit
to rishabhagrawal1/langchain-aws
that referenced
this pull request
Sep 1, 2026
Add ChatOpenAIBedrock, targeting the OpenAI-compatible Chat Completions
and Responses APIs on the bedrock-runtime endpoint
(bedrock-runtime.{region}.amazonaws.com/openai/v1). This is the
recommended endpoint for OpenAI models (e.g. GPT-5.x) on Amazon Bedrock
and supports cross-Region inference via geographic/global inference
profile ids passed as the model
(https://docs.aws.amazon.com/bedrock/latest/userguide/endpoints.html).
Refactor the shared logic out of ChatOpenAIMantle into a private
_BaseChatBedrockOpenAI base so both endpoints share region/base-URL
resolution, Bedrock API-key auth (static bearer token or short-term keys
derived from AWS credentials, following langchain-ai#1203), profile resolution,
LangSmith tracing metadata, and the Chat Completions/Responses routing.
Each public class only sets endpoint-specific class attributes;
ChatOpenAIMantle's public surface is unchanged. The base rejects direct
instantiation with a clear error.
Extract the shared cross-Region prefix stripping and guardrail-rejection
guard into langchain_aws.utils helpers, and route ChatBedrockConverse and
ChatAnthropicMantle through them, removing the duplicated copies (the
guard was previously duplicated per langchain-ai#1225). Behavior is unchanged.
Resolve capability profiles through any cross-Region prefix, so a
geographic id such as us.openai.gpt-5.6-sol reuses the base
openai.gpt-5.6-sol capability profile (mirroring ChatBedrockConverse).
Guardrails are rejected on the OpenAI-compatible path for both endpoints:
bedrock-mantle silently ignores them, and no OpenAI model on
bedrock-runtime accepts them yet.
Rishabh Agrawal (rishabhagrawal1)
added a commit
to rishabhagrawal1/langchain-aws
that referenced
this pull request
Sep 1, 2026
Add ChatOpenAIBedrock, targeting the OpenAI-compatible Chat Completions
and Responses APIs on the bedrock-runtime endpoint
(bedrock-runtime.{region}.amazonaws.com/openai/v1). This is the
recommended endpoint for OpenAI models (e.g. GPT-5.x) on Amazon Bedrock
and supports cross-Region inference via geographic/global inference
profile ids passed as the model
(https://docs.aws.amazon.com/bedrock/latest/userguide/endpoints.html).
Refactor the shared logic out of ChatOpenAIMantle into a private
_BaseChatBedrockOpenAI base so both endpoints share region/base-URL
resolution, Bedrock API-key auth (static bearer token or short-term keys
derived from AWS credentials, following langchain-ai#1203), profile resolution,
LangSmith tracing metadata, and the Chat Completions/Responses routing.
Each public class only sets endpoint-specific class attributes;
ChatOpenAIMantle's public surface is unchanged. The base rejects direct
instantiation with a clear error.
Extract the shared cross-Region prefix stripping and guardrail-rejection
guard into langchain_aws.utils helpers, and route ChatBedrockConverse and
ChatAnthropicMantle through them, removing the duplicated copies (the
guard was previously duplicated per langchain-ai#1225). Behavior is unchanged.
Resolve capability profiles through any cross-Region prefix, so a
geographic id such as us.openai.gpt-5.6-sol reuses the base
openai.gpt-5.6-sol capability profile (mirroring ChatBedrockConverse).
Guardrails are rejected on the OpenAI-compatible path for both endpoints:
bedrock-mantle silently ignores them, and no OpenAI model on
bedrock-runtime accepts them yet.
Rishabh Agrawal (rishabhagrawal1)
added a commit
to rishabhagrawal1/langchain-aws
that referenced
this pull request
Sep 1, 2026
Add ChatOpenAIBedrock, targeting the OpenAI-compatible Chat Completions
and Responses APIs on the bedrock-runtime endpoint
(bedrock-runtime.{region}.amazonaws.com/openai/v1). This is the
recommended endpoint for OpenAI models (e.g. GPT-5.x) on Amazon Bedrock
and supports cross-Region inference via geographic/global inference
profile ids passed as the model
(https://docs.aws.amazon.com/bedrock/latest/userguide/endpoints.html).
Refactor the shared logic out of ChatOpenAIMantle into a private
_BaseChatBedrockOpenAI base so both endpoints share region/base-URL
resolution, Bedrock API-key auth (static bearer token or short-term keys
derived from AWS credentials, following langchain-ai#1203), profile resolution,
LangSmith tracing metadata, and the Chat Completions/Responses routing.
Each public class only sets endpoint-specific class attributes;
ChatOpenAIMantle's public surface is unchanged. The base rejects direct
instantiation with a clear error.
Extract the shared cross-Region prefix stripping and guardrail-rejection
guard into langchain_aws.utils helpers, and route ChatBedrockConverse and
ChatAnthropicMantle through them, removing the duplicated copies (the
guard was previously duplicated per langchain-ai#1225). Behavior is unchanged.
Resolve capability profiles through any cross-Region prefix, so a
geographic id such as us.openai.gpt-5.6-sol reuses the base
openai.gpt-5.6-sol capability profile (mirroring ChatBedrockConverse).
Guardrails are rejected on the OpenAI-compatible path for both endpoints:
bedrock-mantle silently ignores them, and no OpenAI model on
bedrock-runtime accepts them yet.
Rishabh Agrawal (rishabhagrawal1)
added a commit
to rishabhagrawal1/langchain-aws
that referenced
this pull request
Sep 1, 2026
Add ChatOpenAIBedrock, targeting the OpenAI-compatible Chat Completions
and Responses APIs on the bedrock-runtime endpoint
(bedrock-runtime.{region}.amazonaws.com/openai/v1). This is the
recommended endpoint for OpenAI models (e.g. GPT-5.x) on Amazon Bedrock
and supports cross-Region inference via geographic/global inference
profile ids passed as the model
(https://docs.aws.amazon.com/bedrock/latest/userguide/endpoints.html).
Refactor the shared logic out of ChatOpenAIMantle into a private
_BaseChatBedrockOpenAI base so both endpoints share region/base-URL
resolution, Bedrock API-key auth (static bearer token or short-term keys
derived from AWS credentials, following langchain-ai#1203), profile resolution,
LangSmith tracing metadata, and the Chat Completions/Responses routing.
Each public class only sets endpoint-specific class attributes;
ChatOpenAIMantle's public surface is unchanged. The base rejects direct
instantiation with a clear error.
Extract the shared cross-Region prefix stripping and guardrail-rejection
guard into langchain_aws.utils helpers, and route ChatBedrockConverse and
ChatAnthropicMantle through them, removing the duplicated copies (the
guard was previously duplicated per langchain-ai#1225). Behavior is unchanged.
Resolve capability profiles through any cross-Region prefix, so a
geographic id such as us.openai.gpt-5.6-sol reuses the base
openai.gpt-5.6-sol capability profile (mirroring ChatBedrockConverse).
Guardrails are rejected on the OpenAI-compatible path for both endpoints:
bedrock-mantle silently ignores them, and no OpenAI model on
bedrock-runtime accepts them yet.
Rishabh Agrawal (rishabhagrawal1)
added a commit
to rishabhagrawal1/langchain-aws
that referenced
this pull request
Sep 1, 2026
Add ChatOpenAIBedrock, targeting the OpenAI-compatible Chat Completions
and Responses APIs on the bedrock-runtime endpoint
(bedrock-runtime.{region}.amazonaws.com/openai/v1). This is the
recommended endpoint for OpenAI models (e.g. GPT-5.x) on Amazon Bedrock
and supports cross-Region inference via geographic/global inference
profile ids passed as the model
(https://docs.aws.amazon.com/bedrock/latest/userguide/endpoints.html).
Refactor the shared logic out of ChatOpenAIMantle into a private
_BaseChatBedrockOpenAI base so both endpoints share region/base-URL
resolution, Bedrock API-key auth (static bearer token or short-term keys
derived from AWS credentials, following langchain-ai#1203), profile resolution,
LangSmith tracing metadata, and the Chat Completions/Responses routing.
Each public class only sets endpoint-specific class attributes;
ChatOpenAIMantle's public surface is unchanged. The base rejects direct
instantiation with a clear error.
Extract the shared cross-Region prefix stripping and guardrail-rejection
guard into langchain_aws.utils helpers, and route ChatBedrockConverse and
ChatAnthropicMantle through them, removing the duplicated copies (the
guard was previously duplicated per langchain-ai#1225). Behavior is unchanged.
Resolve capability profiles through any cross-Region prefix, so a
geographic id such as us.openai.gpt-5.6-sol reuses the base
openai.gpt-5.6-sol capability profile (mirroring ChatBedrockConverse).
Guardrails are rejected on the OpenAI-compatible path for both endpoints:
bedrock-mantle silently ignores them, and no OpenAI model on
bedrock-runtime accepts them yet.
roi hezkiyahu (roihezkiRaven)
added a commit
to roihezkiRaven/langchain-aws
that referenced
this pull request
Sep 2, 2026
The built client signs with SigV4 only, so a configured `bedrock_api_key` would have been silently ignored and the request authenticated as whatever ambient identity was available — a different identity than the sync path uses. Follows the same raise-on-unsupported approach as langchain-ai#1225. Also replaces the credential test that asserted `asyncio.to_thread` was called with one that measures the observable property: a heartbeat coroutine keeps ticking while a slow credential resolution runs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1224:
Updates
AnthropicBedrockMantleandChatOpenAIMantleto catch and throw an error on user attempts to passX-Amzn-Bedrock-Guardrail*headers, which are currently unsupported on Mantle endpoint.Marked TODO removal, as this is expected to be a temporary mitigation until Mantle guardrails support is added.