Skip to content

Conversation

@evolutiontheory
Copy link
Contributor

Description

Add support for specifying request header allowlist feature which is supported with agent core runtime with the latest release.

This change will extract any request headers passed in which satisfies the pattern below

@pattern("^(Authorization|X-Amzn-Bedrock-AgentCore-Runtime-Custom-[a-zA-Z0-9_-]+)$")

These headers are set in BedrockAgentCoreContext and passed via RequestContext. Sample agent code on how to use this.

@app.entrypoint
def agent_invocation(payload, context: RequestContext):
    """Handler for agent invocation"""
    user_message = payload.get(
        "prompt", "No prompt found in input, please guide customer to create a json payload with prompt key"
    )
    app.logger.info("invoking agent with user message: %s", payload)
    response = agent(user_message)
    print("=== REQUEST CONTEXT ===")
    print(f"RequestContext: {context}")
    print(f"  session_id: {context.session_id}")
    print(f"  session_id: {context.request_headers}")
    app.logger.info("response payload session_id: {context.session_id}: %s", response)
    return response

Related change

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Testing

  • Unit tests pass locally
  • Integration tests pass (if applicable)
  • Test coverage remains above 80%
  • Manual testing completed

Checklist

  • My code follows the project's style guidelines (ruff/pre-commit)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Security Checklist

  • No hardcoded secrets or credentials
  • No new security warnings from bandit
  • Dependencies are from trusted sources
  • No sensitive data logged

Breaking Changes

List any breaking changes and migration instructions:

N/A

Additional Notes

Add any additional notes or context about the PR here.

@evolutiontheory evolutiontheory merged commit 7377187 into main Sep 23, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants