feat: expand custom request header forwarding to match runtime allowlist#483
Merged
Conversation
…list _build_request_context in BedrockAgentCoreApp, BedrockCallContextBuilder (A2A), and AGUIApp previously only forwarded Authorization and headers prefixed with X-Amzn-Bedrock-AgentCore-Runtime-Custom-, silently dropping any other custom headers (e.g. X-Api-Key, X-Custom-Signature) even after the runtime service was updated to forward them to the container. Adds RESTRICTED_HEADERS (frozenset) and is_forwardable_header() to models.py implementing the full allowlist rules from the docs: block the restricted header set, x-amz-* (SigV4 reserved), and x-amzn-* (except the legacy AgentCore custom prefix); pass everything else through.
Contributor
✅ No Breaking Changes DetectedNo public API breaking changes found in this PR. |
notgitika
approved these changes
May 19, 2026
|
|
||
| # Headers that cannot be forwarded to agent code. | ||
| # Source: https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-header-allowlist.html | ||
| RESTRICTED_HEADERS: frozenset[str] = frozenset( |
Contributor
There was a problem hiding this comment.
what if this gets out of sync?
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.
_build_request_context in BedrockAgentCoreApp, BedrockCallContextBuilder (A2A), and AGUIApp previously only forwarded Authorization and headers prefixed with X-Amzn-Bedrock-AgentCore-Runtime-Custom-, silently dropping any other custom headers (e.g. X-Api-Key, X-Custom-Signature) even after the runtime service was updated to forward them to the container.
Adds RESTRICTED_HEADERS (frozenset) and is_forwardable_header() to models.py implementing the full allowlist rules from the docs: block the restricted header set, x-amz-* (SigV4 reserved), and x-amzn-* (except the legacy AgentCore custom prefix); pass everything else through.
Issue #, if available: #468
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.