awslabs / generative-ai-cdk-constructs

AWS Generative AI CDK Constructs are sample implementations of AWS CDK for common generative AI patterns.
https://awslabs.github.io/generative-ai-cdk-constructs/
Apache License 2.0
350 stars 50 forks source link

bedrock: CDK deployments adding action group functions aren't creating versions or updating the agent alias #767

Open titanian229 opened 5 days ago

titanian229 commented 5 days ago

Describe the bug

I've been CDK deploying a stack creating a Bedrock Agent with several action groups, after quite a few successful deployments that created versions and updated the alias no deploy now is creating new Agent Versions or updating the existing alias.

This is the agent's CDK code:

const bedrockAgent = new genAIBedrock.Agent(this, 'bedrock-agent-quiz', {
      foundationModel: genAIBedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_SONNET_V1_0,
      instruction: "Redacted.",
      description: 'Redacted',
      enableUserInput: false,
      existingRole: agentRole,
      name: `bedrockAgent-redacted${suffix}`,
      aliasName: `bedrockAgentAlias-redacted${suffix}`,
      shouldPrepareAgent: true,
      actionGroups: [],
    });

    bedrockAgent.addActionGroup(actionGroupBuild.questionActionGroup);
    bedrockAgent.addActionGroup(actionGroupBuild.createActionGroup);

Documentation says providing an aliasName with shouldPrepareAgent should be creating the version and updating the existing alias that I've previously deployed.

Expected Behavior

CDK deployments of my Bedrock stack should be creating new agent versions and referencing those versions in the existing agent alias.

Current Behavior

I can see my latest action group function definitions in the latest version, and the alias is referencing that version, but it's only seeing the action groups defined at the time of the agent version creation.

Reproduction Steps

  1. CDK deploy stack containing action group with an alias name provided and shouldPrepareAgent on
  2. Add an action group function
  3. CDK deploy stack again

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.163.1

Framework Version

0.1.278

Node.js Version

20

OS

Mac OS 14.4.1

Language

Typescript

Language Version

No response

Region experiencing the issue

us-east-1

Code modification

No

Other information

No response

Service quota

titanian229 commented 2 days ago

After some debugging I can confirm, the issue is the agent alias isn't being updated, it's not unique to the CDK code being deployed as deploying the same stack to a different AWS account updates the alias and creates a new agent version. Looking at CloudTrail events during the deployment I don't see the UpdateAgentAlias or CreateAgentAlias API calls to Bedrock occurring.