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
357 stars 50 forks source link

(bedrock): Class Agent / Interface: AgentProps doesn't detect changes on parameter "instruction", preventing CDK Deploy from updating. #789

Open carlosicc opened 1 week ago

carlosicc commented 1 week ago

Describe the bug

When modifying the Agent Prompt (parameter instruction for Interface AgentProps) in the Agent class, the CDK project doesn't detect any changes; e.g. cdk deploy stack >>> No changes detected. This means I have to edit manually the Agent's instruction or prompt, i.e. via CLI or Console, instead of running a simple CDK DEPLOY.

Example:

agent_instruction = """
You are a friendly virtual assistant for our department store...
... [truncated]
"""

# Create Agent. Hard-coded params: LLM Model. 
agent = bedrock.Agent(self, 'Agent01',
    name='virtual-assistant-agent',
    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0,
    alias_name="virtual-assistant-agent-v1",
    instruction=agent_instruction,
    knowledge_bases=[kb],
    should_prepare_agent=True
)

So, if I modify the value of agent_instruction, CDK DEPLOY doesn't detect this.

Expected Behavior

CDK DEPLOY should detect and redeploy stack.

Current Behavior

CDK Deploy doesn't detect any changes. Resources (e.g. Bedrock agent) need manual intervention.

Reproduction Steps

Deploy the stack with X agent_instruction. Modify the agent_instruction Redeploy stack

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.156.0

Framework Version

No response

Node.js Version

v20.5.0

OS

MacOS Sonoma Version 14.7 (23H124)

Language

Python

Language Version

No response

Region experiencing the issue

us-west-2

Code modification

N/A

Other information

No response

Service quota

aws-rafams commented 4 days ago

Hi Carlos! Thanks for reaching out!

Unfortunately I did not manage to replicate the issue. Could you share with us the library version you're using? Could you also run cdk diff after saving a change to the instruction parameter and send us a screenshot?

Thanks!