Description
When invoking an agent with CUSTOM_JWT authentication, custom headers passed via the -H or --header flag are silently ignored.
Steps to Reproduce
- Configure an agent with
authorizerType: "CUSTOM_JWT" in agentcore.json
- Deploy the agent:
agentcore deploy
- Invoke with custom headers:
agentcore invoke -H "Foo-Header: bar"
- In the agent code, check
context.request_headers
Expected Behavior
Headers include x-amzn-bedrock-agentcore-runtime-custom-foo-header
Actual Behavior
Headers are empty
CLI Version
0.12.0
Operating System
macOS
Additional Context
Seems the root cause is in https://github.com/aws/agentcore-cli/blob/main/src/cli/aws/agentcore.ts#L159 - headers does not include options.headers
Suggested fix:
Merge custom headers in the bearer token path:
async function invokeWithBearerTokenStreaming(options: InvokeAgentRuntimeOptions): Promise<StreamingInvokeResult> {
const url = buildInvokeUrl(options.region, options.runtimeArn);
const headers: Record<string, string> = {
Authorization: `Bearer ${options.bearerToken}`,
'Content-Type': 'application/json',
Accept: 'application/json, text/event-stream',
...options.headers, // <<< ADD THIS
};
Description
When invoking an agent with
CUSTOM_JWTauthentication, custom headers passed via the-Hor--headerflag are silently ignored.Steps to Reproduce
authorizerType: "CUSTOM_JWT"in agentcore.jsonagentcore deploycontext.request_headersExpected Behavior
Headers include
x-amzn-bedrock-agentcore-runtime-custom-foo-headerActual Behavior
Headers are empty
CLI Version
0.12.0
Operating System
macOS
Additional Context
Seems the root cause is in https://github.com/aws/agentcore-cli/blob/main/src/cli/aws/agentcore.ts#L159 -
headersdoes not includeoptions.headersSuggested fix:
Merge custom headers in the bearer token path: