Associate a knowledge base with an Amazon Bedrock agent - Amazon Bedrock

Associate a knowledge base with an Amazon Bedrock agent

If you haven't yet created a knowledge base, see Knowledge bases for Amazon Bedrock to learn about knowledge bases and create one. You can associate a knowledge base during agent creation or after an agent has been created. To associate a knowledge base to an existing agent, select the tab corresponding to your method of choice and follow the steps.

Console
To add a knowledge base
  1. Sign in to the AWS Management Console using an IAM role with Amazon Bedrock permissions, and open the Amazon Bedrock console at https://console.aws.amazon.com/bedrock/.

  2. Select Agents from the left navigation pane. Then, choose an agent in the Agents section.

  3. Choose Edit in Agent builder

  4. For the Knowledge bases section, choose Add.

  5. Choose a knowledge base that you have created and provide instructions for how the agent should interact with it.

  6. Choose Add. A success banner appears at the top.

  7. To apply the changes that you made to the agent before testing it, choose Prepare before testing it.

API

To associate a knowledge base with an agent, send an AssociateAgentKnowledgeBase request with a Agents for Amazon Bedrock build-time endpoint.

The following list describes the fields in the request:

  • The following fields are required:

    Field Short description
    agentId ID of the agent
    agentVersion Version of the agent
    knowledgeBaseId ID of the knowledge base
  • The following fields are optional:

    Field Short description
    description Description of how the agent can use the knowledge base
    knowledgeBaseState To prevent the agent from querying the knowledge base, specify DISABLED

You can modify the query configurations of a knowledge base attached to your agent by using the sessionState field in the InvokeAgent request when you invoke your agent. For more information, see Control session context.