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

[Bug]: aws_bedrockagent_agent prompt override block causes missing required field, UpdateAgentInput.PromptOverrideConfiguration.PromptConfigurations error #37903

Closed
kmcduffee-verisk opened this issue Jun 10, 2024 · 9 comments
Labels
bug Addresses a defect in current functionality. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/bedrockagent Issues and PRs that pertain to the bedrockagent service.

Comments

@kmcduffee-verisk
Copy link

Terraform Core Version

1.8.5

AWS Provider Version

5.53.0

Affected Resource(s)

  • aws_bedrockagent_agent

Expected Behavior

Ability to apply the aws_bedrockagent_agent resource with custom prompt_override_configuration.

Actual Behavior

Apply does not succeed. The following error appears on terraform apply:

│ operation error Bedrock Agent: UpdateAgent, 1 validation error(s) found.
│ - missing required field, UpdateAgentInput.PromptOverrideConfiguration.PromptConfigurations.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_bedrockagent_agent" "test" {
  agent_name                  = "test"
  agent_resource_role_arn     = aws_iam_role.test.arn
  prepare_agent               = true
  foundation_model            = "anthropic.claude-3-sonnet-20240229-v1:0"
  idle_session_ttl_in_seconds = 60
  instruction = "Something here"
  prompt_override_configuration {
    prompt_configurations = [
      {
        base_prompt_template = file("${path.module}/prompt_templates/post_processing.json")
        inference_configuration = [
          {
            max_length     = 2048
            stop_sequences = ["\n\nHuman:"]
            temperature    = 0
            top_k          = 250
            top_p          = 1
          }
        ]
        parser_mode          = "DEFAULT"
        prompt_creation_mode = "OVERRIDDEN"
        prompt_state         = "ENABLED"
        prompt_type          = "POST_PROCESSING"
      }
    ]
  }
}

Steps to Reproduce

  • terraform apply with the includes resource definition. It will succeed to create the agent if the prompt_override_configuration is left out.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

@kmcduffee-verisk kmcduffee-verisk added the bug Addresses a defect in current functionality. label Jun 10, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/bedrockagent Issues and PRs that pertain to the bedrockagent service. label Jun 10, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Jun 10, 2024
@justinretzolk justinretzolk added prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. and removed needs-triage Waiting for first response or review from a maintainer. labels Jun 11, 2024
@drewtul
Copy link
Contributor

drewtul commented Aug 19, 2024

@kmcduffee-verisk Looking at your error you created the agent without any prompts then updated it to add one?

@kmcduffee-verisk
Copy link
Author

@drewtul It seems to happen either way.

@drewtul
Copy link
Contributor

drewtul commented Aug 20, 2024

@kmcduffee-verisk Does it happen on the first apply or the second, I can provoke an error by providing some overrides but not all and I've got a fix for this, but I'm not getting the same error as you.

@drewtul
Copy link
Contributor

drewtul commented Aug 20, 2024

@kmcduffee-verisk I can reproduce your error, but only by having a block:

resource "aws_bedrockagent_agent" "test" {
  agent_name                  = "test"
  agent_resource_role_arn     = aws_iam_role.test.arn
  prepare_agent               = true
  foundation_model            = "anthropic.claude-3-sonnet-20240229-v1:0"
  idle_session_ttl_in_seconds = 60
  instruction = "Something here"
  prompt_override_configuration {
  }
}

Can you double check you don't have any typo on prompt_configurations in your configuration?

@kmcduffee-verisk
Copy link
Author

@drewtul Thanks for digging in! Indeed, the issue appears to have been with my prompt template file. In the AWS UI, where the JSON worked fine as-is, there was a newline after the first quote of the content block. Once I brought the text back up to the quote, it all worked.

I did run into an issue related to #37168 though. It appears that if you do not provide prompt configurations for every prompt (orchestration, pre, knowledge, post), you will get the error noted there. I was only able to get bast that issue doing the following, basically blanking out the other options (since my agent does not use them):

  prompt_override_configuration {
    prompt_configurations = [
      {
        base_prompt_template = "{\"anthropic_version\":\"bedrock-2023-05-31\",\"system\":\"\",\"messages\":[{\"role\":\"user\",\"content\":\"\"}]}"
        inference_configuration = [
          {
            max_length     = 2048
            stop_sequences = ["\n\nHuman:"]
            temperature    = 0
            top_k          = 250
            top_p          = 1
          }
        ]
        parser_mode          = "DEFAULT"
        prompt_creation_mode = "OVERRIDDEN"
        prompt_state         = "DISABLED"
        prompt_type          = "PRE_PROCESSING"
      },
      {
        base_prompt_template = "{\"anthropic_version\":\"bedrock-2023-05-31\",\"system\":\"\",\"messages\":[{\"role\":\"user\",\"content\":\"\"}]}"
        inference_configuration = [
          {
            max_length     = 2048
            stop_sequences = ["\n\nHuman:"]
            temperature    = 0
            top_k          = 250
            top_p          = 1
          }
        ]
        parser_mode          = "DEFAULT"
        prompt_creation_mode = "OVERRIDDEN"
        prompt_state         = "DISABLED"
        prompt_type          = "ORCHESTRATION"
      },
      {
        base_prompt_template = "You are not a knowledge base assistant."
        inference_configuration = [
          {
            max_length     = 2048
            stop_sequences = ["\n\nHuman:"]
            temperature    = 0
            top_k          = 250
            top_p          = 1
          }
        ]
        parser_mode          = "DEFAULT"
        prompt_creation_mode = "OVERRIDDEN"
        prompt_state         = "DISABLED"
        prompt_type          = "KNOWLEDGE_BASE_RESPONSE_GENERATION"
      },
      {
        base_prompt_template = file("${path.module}/prompt_templates/post_processing.json")
        inference_configuration = [
          {
            max_length     = 2048
            stop_sequences = ["\n\nHuman:"]
            temperature    = 0
            top_k          = 250
            top_p          = 1
          }
        ]
        parser_mode          = "DEFAULT"
        prompt_creation_mode = "OVERRIDDEN"
        prompt_state         = "ENABLED"
        prompt_type          = "POST_PROCESSING"
      }
    ]
  }

Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@drewtul
Copy link
Contributor

drewtul commented Aug 21, 2024

@kmcduffee-verisk I did encounter the error from #37168 and I've raised a PR to fix that issue with some further tests covering adding/removing and partial prompt configuration.

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/bedrockagent Issues and PRs that pertain to the bedrockagent service.
Projects
None yet
Development

No branches or pull requests

3 participants