Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom resource returned: Error: 'agentVersion' #423

Closed
1 task done
InitialXW opened this issue May 3, 2024 · 5 comments · Fixed by #441
Closed
1 task done

custom resource returned: Error: 'agentVersion' #423

InitialXW opened this issue May 3, 2024 · 5 comments · Fixed by #441
Labels
bug Something isn't working needs-triage This issue or PR still needs to be triaged.

Comments

@InitialXW
Copy link

InitialXW commented May 3, 2024

Describe the bug

custom resource returned error when creating Agent (errorred out in us-west-2, us-east-1 seems to be fine):

[BedrockCRProviderCustomResources log:
[ERROR] KeyError: 'agentVersion'
Traceback (most recent call last):
File "/var/task/custom_resources/init.py", line 47, in on_event
return on_event_bedrock_agent_alias(event, context)
File "/var/task/custom_resources/bedrock_agent_alias.py", line 81, in on_event
return on_create(event, str(uuid.uuid1()))
File "/var/task/custom_resources/bedrock_agent_alias.py", line 311, in on_create
response = create_agent_alias(agent_id, alias_name, session, agent_version, client_token)
File "/var/task/tenacity/init.py", line 289, in wrapped_f
return self(f, *args, **kw)
File "/var/task/tenacity/init.py", line 379, in call
do = self.iter(retry_state=retry_state)
File "/var/task/tenacity/init.py", line 314, in iter
return fut.result()
File "/var/lang/lib/python3.12/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
File "/var/lang/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/var/task/tenacity/init.py", line 382, in call
result = fn(*args, **kwargs)
File "/var/task/custom_resources/bedrock_agent_alias.py", line 200, in create_agent_alias
agent_version = get_version(
File "/var/task/custom_resources/bedrock_agent_alias.py", line 169, in get_version
return routing_configuration[0]["agentVersion"]

Expected Behavior

Agent create success

Current Behavior

cdk stack deployment fails

Reproduction Steps

import * as cdk from 'aws-cdk-lib';
import { bedrock } from '@cdklabs/generative-ai-cdk-constructs';
import { Construct } from 'constructs';

export interface KbStatefulProps extends cdk.StackProps {
}

export class KbStatefulStack extends cdk.Stack {

constructor(scope: Construct, id: string, props: KbStatefulProps) {
super(scope, id, props);

const knowledgeBase = new bedrock.KnowledgeBase(this, 'BedrockKnowledgeBase', {
  embeddingsModel: bedrock.BedrockFoundationModel.TITAN_EMBED_TEXT_V1,
  instruction: `you are a knowledgeable base that answers all questions`,
});

const tamAgent = new bedrock.Agent(this, 'MyAgent', {
  name: 'MyAgent',
  description: 'The agent for consultation on any example issues.',
  foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2,
  instruction:
    'You are a useful agent that provides details or advices related to any issues.',
  idleSessionTTL: cdk.Duration.minutes(15),
  knowledgeBases: [knowledgeBase],
  shouldPrepareAgent: false,
  aliasName: 'exampleAliasName',
});

}
}

Possible Solution

bedrock_agent_alias.py line 169, change to 'return routing_configuration[0].get("agentVersion")'

Additional Information/Context

No response

CDK CLI Version

2.139.0 (build 2699ffd)

Framework Version

0.1.134

Node.js Version

20

OS

Linux

Language

Typescript

Language Version

No response

Region experiencing the issue

us-west-2

Code modification

no

Other information

No response

Service quota

  • I have reviewed the service quotas for this construct
@InitialXW InitialXW added bug Something isn't working needs-triage This issue or PR still needs to be triaged. labels May 3, 2024
@krokoko
Copy link
Collaborator

krokoko commented May 7, 2024

Hi @InitialXW , thank you for reporting this issue. I was not able to reproduce, however we are working on updating this construct to use the official L1 Bedrock constructs, which will remove the custom resource and probably fix this on your end. I will update this ticket when the work is done

@leegilmorecode
Copy link

Also seeing this issue now since upgrading the package to version 0.1.140, can't actually deploy my stack at all now and this is blocking. Example to reproduce here: https://github.com/leegilmorecode/serverless-amazon-bedrock-agents

@krokoko
Copy link
Collaborator

krokoko commented May 9, 2024

@leegilmorecode do you also see this error in us-west-2 ?

@leegilmorecode
Copy link

us-east-1 is where it was previously working fine. I’ve only updated this package from version 0.1.72 and I’m now getting the error. I can’t seem to get past it and deploy.

@InitialXW
Copy link
Author

@leegilmorecode, please see my suggested fix in my post to unblock you till there is a perm fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage This issue or PR still needs to be triaged.
Development

Successfully merging a pull request may close this issue.

3 participants