feat(ai): add AWS ECS/IRSA credential detection for Bedrock, fixes #848

Added support for additional AWS credential environment variables:
- AWS_CONTAINER_CREDENTIALS_RELATIVE_URI (ECS task roles)
- AWS_CONTAINER_CREDENTIALS_FULL_URI (ECS task roles)
- AWS_WEB_IDENTITY_TOKEN_FILE (IRSA for Kubernetes)

Also fixed undefined currentModel variable in OAuth error handling.
This commit is contained in:
Mario Zechner 2026-01-19 16:09:59 +01:00
parent cd0df4c0dd
commit 2b04aefa6d
3 changed files with 17 additions and 6 deletions

View file

@ -641,17 +641,18 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
}
const key = await modelRegistry.getApiKeyForProvider(resolvedProvider);
if (!key) {
const isOAuth = modelRegistry.isUsingOAuth(currentModel);
const model = agent.state.model;
const isOAuth = model && modelRegistry.isUsingOAuth(model);
if (isOAuth) {
throw new Error(
`Authentication failed for "${currentModel.provider}". ` +
`Authentication failed for "${resolvedProvider}". ` +
`Credentials may have expired or network is unavailable. ` +
`Run '/login ${currentModel.provider}' to re-authenticate.`,
`Run '/login ${resolvedProvider}' to re-authenticate.`,
);
}
throw new Error(
`No API key found for "${currentModel.provider}". ` +
`Set an API key environment variable or run '/login ${currentModel.provider}'.`,
`No API key found for "${resolvedProvider}". ` +
`Set an API key environment variable or run '/login ${resolvedProvider}'.`,
);
}
return key;