7.8 C
Canberra
Friday, June 12, 2026

Constructing AI buying agent utilizing Amazon Bedrock AgentCore Runtime and Amazon OpenSearch Service


On this publish, we discover construct a web based buying AI agent. We concentrate on its structure and implementation with Amazon OpenSearch Service, Amazon Bedrock AgentCore, and Strands Brokers. Amazon Bedrock AgentCore is an agentic platform for deploying and working these brokers and instruments securely at scale with out managing infrastructure. AgentCore Runtime is the safe, serverless runtime that hosts your Strands Brokers and instruments as containerized functions. Strands Brokers is an open supply SDK for constructing AI brokers. On this SDK, an agent is outlined by a mannequin, instruments, and a immediate. Instruments are callable features that enable brokers to carry out actions past textual content technology, akin to API calls, database queries, and file operations. The framework lets the mannequin autonomously plan steps and invoke instruments to finish duties.

At present’s AI buying assistants perceive pure language, context, and buying intent, making a extra human-like interplay. These assistants deal with advanced buying necessities, akin to “Discover me a proper gown beneath $200 that’s acceptable for a summer time wedding ceremony.” They keep dialog historical past, course of follow-up questions naturally, and supply customized suggestions primarily based on consumer preferences and previous interactions. Prospects can use visible search to add photographs of things that they need, and the AI finds comparable merchandise throughout a number of retailers, matching kinds and patterns. The aim is to offer prompt, related, and customized help at scale, making a extra environment friendly buying journey for customers worldwide.

AI brokers mixed with Retrieval Augmented Technology (RAG) on Amazon OpenSearch Service symbolize an evolution in conversational search. This integration builds AI brokers on enriched catalogs, supporting context-aware and autonomous search experiences whereas sustaining accuracy and relevance by grounded responses.

Answer overview

The next diagram illustrates the answer structure of an AI-powered on-line buying agent constructed utilizing Strands Brokers, Amazon Bedrock AgentCore Runtime, and Amazon OpenSearch Service. For simplicity, the diagram doesn’t present authentication and authorization. In a manufacturing setup, safe entry to the backend through the use of mechanisms akin to Amazon API Gateway, AWS Id and Entry Administration (IAM) roles, or OAuth-based authentication.

Architecture diagram showing an AI shopping agent: a user prompt flows from the front end to AgentCore Runtime, which routes the request to a Strands Retail Agent that calls a search tool against Amazon OpenSearch Service and an Amazon Bedrock LLM, then returns a natural-language response to the user.

The next is a walkthrough of the reference structure:

  1. The consumer submits a query by the front-end utility. AgentCore Runtime receives the request and routes it to the Strands Retail Agent.
  2. The Strands Agent processes the duty and invokes the search_product_catalog software.
  3. OpenSearch Service performs semantic search and returns related product outcomes.
  4. The Strands Agent invokes Amazon Bedrock massive language fashions (LLMs) to generate a pure language response.
  5. The agent response is returned to the consumer by the entrance finish.

Walkthrough

The next part walks you thru construct a web based buying AI agent.

Stipulations

To implement this answer, you want an AWS account. You additionally want an OpenSearch Service area with OpenSearch model 2.13 or later. You should use an present area or create a brand new area.

To make use of the vector search capabilities of OpenSearch Service with Strands Brokers on AgentCore, you utilize ingest pipelines. These ingestion pipelines apply built-in processors to pre-process your paperwork earlier than you index them in OpenSearch Service.

You utilize the text_embedding processor, which depends on the ML Commons plugin and a registered embedding mannequin—Amazon Nova Multimodal Embeddings on Amazon Bedrock. OpenSearch Service makes use of the ML Commons plugin to generate vector embedding to your information and makes use of the identical mannequin to transform incoming queries into vectors. This helps semantic search throughout your listed content material.

You lengthen your semantic search backend by including an agent constructed with Strands Brokers and deployed on Amazon Bedrock AgentCore.

Code samples offered on this publish are examined in Python 3.11. You solely want to put in Python 3.11 in your surroundings to execute the python scripts. You additionally want Node.js 18 or later put in to make use of the AgentCore CLI. The offered code scripts will deploy into your AWS account so make sure that your terminal has entry to needed AWS credentials.

Set up AgentCore CLI

Set up the AgentCore CLI globally utilizing npm:

npm set up -g @aws/agentcore

Python Dependencies

You additionally have to create a necessities.txt file with following dependencies in your workspace to deploy the brokers.

boto3
uv
opensearch-py
requests-aws4auth
strands-agents
strands-agents-tools
bedrock-agentcore

Run pip set up -r necessities.txt in your terminal to put in the required dependencies. To keep away from conflicts with different dependencies in your system, you should use a digital surroundings.

Now, stroll by every step.

Step 1: Configure IAM permissions

Full the next steps to register the Nova Multimodal Embeddings mannequin with OpenSearch Service and confirm that your OpenSearch Service area has permission to invoke the Amazon Bedrock API.

  1. Go to the IAM console and create a brand new function with a {custom} belief coverage. Add the next belief coverage.
    {
      "Model": "2012-10-17",
      "Assertion": [
        {
          "Sid": "Statement1",
          "Effect": "Allow",
          "Principal": {
            "Service": "opensearchservice.amazonaws.com"
          },
          "Action": "sts:AssumeRole"
        }
      ]
    }

  2. Skip including a permission coverage.
  3. Give your function a reputation and create it. For this publish, we use OpenSearchBedrockEmbeddingRole because the function title. OpenSearch Service makes use of this function to invoke the Nova Multimodal Embeddings mannequin on Amazon Bedrock.
  4. On the Permissions tab, connect an inline coverage with the next permissions. For this publish, we title this coverage OpenSearchBedrockEmbeddingPolicy.
    {
      "Model": "2012-10-17",
      "Assertion": [
        {
          "Sid": "Statement1",
          "Effect": "Allow",
          "Action": [
            "bedrock:InvokeAgent",
            "bedrock:InvokeModel"
          ],
          "Useful resource": [
            "arn:aws:bedrock:us-east-1::foundation-model/*"
          ]
        }
      ]
    }

  5. Create a passRole coverage with the next JSON doc and assign it to the IAM function that creates the ML connector. This lets the principal working the Python code move the OpenSearchBedrockEmbeddingRole to OpenSearch. Substitute with your personal AWS account ID.
    {
      "Model": "2012-10-17",
      "Assertion": [
        {
          "Effect": "Allow",
          "Action": "iam:PassRole",
          "Resource": "arn:aws:iam::$:role/OpenSearchBedrockEmbeddingRole"
        }
      ]
    }

  6. Through the use of fine-grained entry management (FGAC), map the IAM function as a backend function for the ml_full_access function within the OpenSearch Dashboards Safety plugin. This mapping lets the consumer create ML connectors:
    1. Log in to OpenSearch Dashboards and open the Safety web page from the navigation menu.
    2. Select Roles and choose ml_full_access.
    3. Select Mapped Customers and Handle Mapping.
    4. Below Backend roles, add the ARN of the IAM function that you just created within the earlier steps.

Animated demo of OpenSearch Dashboards Security plugin showing the ml_full_access role with the Mapped Users tab open and an IAM role being added as a backend role.

Step 2: Connect with the mannequin through the use of OpenSearch ML Connectors

On this part, you create an ML connector to hyperlink OpenSearch Service with the Bedrock Nova Multimodal Embeddings mannequin. You then register and deploy the mannequin so you should use it for neural search queries.

  1. Create a file named create-connector.py with the next code. Substitute , , and placeholders throughout the code.
import boto3
import requests
from requests_aws4auth import AWS4Auth
host=""##CHANGE THIS
area = '' ##CHANGE THIS
account_id = '' ##CHANGE THIS
service="es"
credentials = boto3.Session().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, area, service, session_token=credentials.token)
path="/_plugins/_ml/connectors/_create"
url = host + path
payload = {
"title": "Amazon Bedrock Nova multimodal mannequin - textual content embedding",
"description": "Take a look at connector for Amazon Bedrock Nova multimodal mannequin - textual content embedding",
"model": 1,
"protocol": "aws_sigv4",
"credential": {
"roleArn": f"arn:aws:iam::{account_id}:function/OpenSearchBedrockEmbeddingRole"
},
"parameters": {
"area": area,
"service_name": "bedrock",
"mannequin": "amazon.nova-2-multimodal-embeddings-v1:0",
"input_docs_processed_step_size": 1,
"dimensions": 1024,
"embeddingTypes": [
"float"
],
"truncationMode": "NONE"
},
"actions": [
{
"action_type": "predict",
"method": "POST",
"headers": {
"content-type": "application/json",
"x-amz-content-sha256": "required"
},
"url": "https://bedrock-runtime.${parameters.region}.amazonaws.com/model/${parameters.model}/invoke",
"request_body": "{n "taskType": "SINGLE_EMBEDDING",n "singleEmbeddingParams": {n "embeddingPurpose": "GENERIC_INDEX",n "embeddingDimension": ${parameters.dimensions},n "text": {n "truncationMode": "${parameters.truncationMode}",n "value": "${parameters.inputText}"n }n }n}",
"pre_process_function": "connector.pre_process.bedrock.nova.text_embedding",
"post_process_function": "connector.post_process.bedrock.nova.embedding"
}
]
}
headers = {"Content material-Kind": "utility/json"}
r = requests.publish(url, auth=awsauth, json=payload, headers=headers, timeout=15)
print(r.status_code)
print(r.textual content)

  1. Run python create-connector.py in your terminal through the use of the IAM function with ml_full_access and passRole permissions created within the earlier step. This script creates a connector between OpenSearch Service and the Bedrock Nova Multimodal Embeddings mannequin.
  2. This system responds with connector_id. Take a word of it. Then, navigate to OpenSearch Dashboards and open Dev Instruments. Create a mannequin group in opposition to which to register this mannequin within the OpenSearch Service area.
POST /_plugins/_ml/model_groups/_register
{
  "title": "agent-conversational-search-model-group",
  "description": "A mannequin group for bedrock Nova embedding fashions used for conversational search"
}

  1. Register a mannequin through the use of connector_id and model_group_id.
POST /_plugins/_ml/fashions/_register
{
  "title": "nova-2-multimodal-embedding-v1",
  "function_name": "distant",
  "model_group_id": "",
  "description": "Nova 2 Multimodal Embeddings Mannequin",
  "connector_id": "",
  "interface": {}
}

  1. Run the next API name to deploy the mannequin. Use the registered mannequin ID from the earlier step.
POST /_plugins/_ml/fashions//_deploy

Step 3: Create an ingest pipeline for information indexing

Use the next code to create an ingest pipeline for information indexing. The pipeline establishes a connection to the embedding mannequin, retrieves the embedding for the title subject, and shops it within the OpenSearch index.

PUT /_ingest/pipeline/nova_multimodal_embedding
{
  "description": "Textual content embedding pipeline utilizing nova_multimodal_embedding",
  "processors": [
    {
      "text_embedding": {
        "model_id": "",
        "field_map": {
          "title": "title_vector"
        }
      }
    }
  ]
}

Step 4: Create an index for storing information

Create an index named product for storing information through the use of Dev Instruments. This index shops uncooked textual content and 1024-dimensional embeddings of the title subject, and makes use of the ingest pipeline you created within the earlier step.

PUT /product
{
  "settings": {
    "index": {
      "default_pipeline": "nova_multimodal_embedding",
      "knn": true
    }
  },
  "mappings": {
    "properties": {
      "title": {
        "sort": "textual content",
        "analyzer": "commonplace"
      },
      "title_vector": {
        "sort": "knn_vector",
        "dimension": 1024,
        "methodology": {
          "title": "hnsw",
          "space_type": "cosinesimil",
          "engine": "lucene"
        }
      },
      "value": {
        "sort": "float"
      },
      "description": {
        "sort": "textual content"
      },
      "class": {
        "sort": "key phrase"
      },
      "image_url": {
        "sort": "textual content"
      },
      "score": {
        "properties": {
          "price": {
            "sort": "float"
          },
          "rely": {
            "sort": "integer"
          }
        }
      }
    }
  }
}

Step 5: Ingest pattern information

Use the next code to ingest the pattern product information in Dev Instruments.

POST /_bulk
{"index": {"_index": "product", "_id": "2"}}
{"id":2,"title":"Mens Informal Premium Slim Match T-Shirts","value":22.3,"description":"Slim-fitting type, distinction raglan lengthy sleeve, three-button henley placket, gentle weight & gentle material for breathable and cozy sporting.","class":"males's clothes","picture":"https://fakestoreapi.com/img/71-3HjGNDUL._AC_SY879._SX._UX._SY._UY_.jpg","score":{"price":4.1,"rely":259}}
{"index": {"_index": "product", "_id": "3"}}
{"id":3,"title":"Mens Cotton Jacket","value":55.99,"description":"nice outerwear jackets for Spring/Autumn/Winter, appropriate for a lot of events, akin to working, mountain climbing, tenting, mountain/mountaineering, biking, touring or different outside.","class":"males's clothes","picture":"https://fakestoreapi.com/img/71li-ujtlUL._AC_UX679_.jpg","score":{"price":4.7,"rely":500}}
{"index": {"_index": "product", "_id": "4"}}
{"id":4,"title":"Mens Informal Slim Match","value":15.99,"description":"The colour may very well be barely completely different between on the display and in apply.","class":"males's clothes","picture":"https://fakestoreapi.com/img/71YXzeOuslL._AC_UY879_.jpg","score":{"price":2.1,"rely":430}}
{"index": {"_index": "product", "_id": "5"}}
{"id":5,"title":"John Hardy Ladies's Legends Naga Gold & Silver Dragon Station Chain Bracelet","value":695,"description":"From our Legends Assortment, the Naga was impressed by the legendary water dragon that protects the ocean's pearl.","class":"jewelery","picture":"https://fakestoreapi.com/img/71pWzhdJNwL._AC_UL640_QL65_ML3_.jpg","score":{"price":4.6,"rely":400}}

Step 6: Question the index

Run the next API name to check semantic search through the use of the Nova Multimodal Embeddings mannequin.

GET /product/_search
{
  "_source": false,
  "fields": [
    "title",
    "price",
    "category",
    "image"
  ],
  "measurement": 3,
  "question": {
    "neural": {
      "title_vector": {
        "query_text": "jacket",
        "model_id": "",
        "okay": 5
      }
    }
  }
}

The output of the previous question ought to appear like the next.

{
  ...
  "hits": {
    "complete": {
      "worth": 4,
      "relation": "eq"
    },
    "max_score": 0.8333229,
    "hits": [
      {
        "_index": "product",
        "_id": "3",
        "_score": 0.8333229,
        "fields": {
          "image": [
            "https://fakestoreapi.com/img/71li-ujtlUL._AC_UX679_.jpg"
          ],
          "title": [
            "Mens Cotton Jacket"
          ],
          "class": [
            "men's clothing"
          ],
          "value": [
            55.99
          ]
        }
      }
      ...
    ]
  }
}

Step 7: Create an agent with Strands and Bedrock AgentCore Runtime

Now, create the Strands Agent that makes use of Anthropic Claude Sonnet 4.6 on Amazon Bedrock to go looking merchandise from the OpenSearch Service index. To take action:

  • Import the Runtime app with from bedrock_agentcore.runtime import BedrockAgentCoreApp.
  • Initialize the app in your code with app = BedrockAgentCoreApp().
  • Create the OpenSearch Service connection and search question with the @software decorator.
  • Enhance the invocation perform with the @app.entrypoint decorator.
  • Let AgentCore Runtime management the working of the agent with app.run().

Now, full the next steps:

  1. Just remember to have put in the mandatory dependencies from the Stipulations part of this publish.
  2. Create and save a file named search_agent.py with the next code. Substitute , , and placeholders throughout the code.
    from strands import Agent, software
    import argparse
    import json
    from bedrock_agentcore.runtime import BedrockAgentCoreApp
    from strands.fashions import BedrockModel
    import boto3
    from opensearchpy import OpenSearch, RequestsHttpConnection
    from requests_aws4auth import AWS4Auth
    app = BedrockAgentCoreApp()
    @software
    def search_products(question: str, measurement: int = 5):
    attempt:
    # OpenSearch configuration
    host="" ## CHANGE THIS, DOMAIN ENDPOINT WITHOUT HTTPS!
    area = '' ##CHANGE THIS
    model_id= '' ##CHANGE THIS together with your deployed mannequin id in OpenSearch
    service="es"
    credentials = boto3.Session().get_credentials()
    awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, area, service, session_token=credentials.token)
    # Create OpenSearch shopper
    shopper = OpenSearch(
    hosts=[{'host': host, 'port': 443}],
    http_auth=awsauth,
    use_ssl=True,
    verify_certs=True,
    connection_class=RequestsHttpConnection
    )
    """Search merchandise in OpenSearch utilizing neural search"""
    search_body = {
    "_source": False,
    "fields": ["title", "price", "category", "image"],
    "measurement": measurement,
    "question": {
    "neural": {
    "title_vector": {
    "query_text": question,
    "model_id": model_id,
    "okay": 3
    }
    }
    }
    }
    response = shopper.search(
    physique=search_body,
    index="product"
    )
    merchandise = []
    for hit in response['hits']['hits']:
    fields = hit.get('fields', {})
    product = {
    'title': fields.get('title', [''])[0] if fields.get('title') else '',
    'value': fields.get('value', [''])[0] if fields.get('value') else '',
    'class': fields.get('class', [''])[0] if fields.get('class') else '',
    'picture': fields.get('picture', [''])[0] if fields.get('picture') else ''
    }
    merchandise.append(product)
    return f"Discovered {len(merchandise)} merchandise: {json.dumps(merchandise, indent=2)}"
    besides Exception as e:
    return f"Search error: {str(e)}"
    model_id = "world.anthropic.claude-haiku-4-5-20251001-v1:0"
    mannequin = BedrockModel(
    model_id=model_id,
    )
    agent = Agent(
    mannequin=mannequin,
    instruments=[search_products],
    system_prompt="You are a useful assistant. You are able to do product search, and inform the product particulars."
    )
    @app.entrypoint
    def strands_agent_bedrock(payload):
    """
    Invoke the agent with a payload
    """
    user_input = payload.get("immediate")
    print("Person enter:", user_input)
    response = agent(user_input)
    return response.message['content'][0]['text']
    if __name__ == "__main__":
    #strands_agent_bedrock({"immediate": "Search jacket"}) ##UNCOMMENT THIS FOR TESTING
    #app.run() ##UNCOMMENT THIS FOR DEPLOYMENT, MAKE SURE THE ABOVE LINE IS COMMENTED WHEN YOU ARE DEPLOYING TO AGENTCORE

    This deploys your agent regionally for testing functions.

  3. Navigate to the IAM console and add the AmazonBedrockLimitedAccess permission coverage to the principal working the code.
  4. Navigate to OpenSearch Dashboards and, from the left menu, select Safety plugin, then select Roles.
  5. Select Create Function.
  6. Title the function agentcore-permissions.
  7. Below cluster permissions, add cluster:admin/opensearch/ml/fashions/get and cluster:admin/opensearch/ml/predict.
  8. Below index permissions, enter product* because the index sample. Add search and get permissions.
  9. Create the function.
  10. Select the function you created, swap to the Mapped Customers tab, select Handle mapping, and add the function that you just use for working the Python code as a backend function.
  11. Uncomment the road strands_agent_bedrock({"immediate": "Search jacket"}) and ensure the app.run() line is commented within the code.
  12. Run python search_agent.py in your terminal to begin the buying agent. The output ought to look much like the next.
    "Listed here are the jacket search outcomes:nn1. **Mens Cotton Jacket** - $55.99n2. **Mens Informal Slim Match** - $15.99n3. **Mens Informal Premium Slim Match T-Shirts** - $22.30n4. **John Hardy Ladies's Legends Naga Gold & Silver Dragon Station Chain Bracelet** - $695.00nnThe most related jacket choice is the **Mens Cotton Jacket** at $55.99. Would you prefer to know extra about any of those merchandise?

  13. Remark strands_agent_bedrock({"immediate": "Search jacket"}) and uncomment the app.run() line within the code earlier than going into the following step.

Step 8: Configure and launch your agent to Bedrock AgentCore Runtime

The AgentCore CLI is a command-line software offered by AWS that simplifies deployment of brokers to Amazon Bedrock AgentCore Runtime. While you run the CLI deployment command, it automates all the deployment workflow: it creates the mandatory IAM execution function with correct permissions, packages your Python utility code together with its dependencies, makes use of AWS CodeBuild to construct an optimized Docker container picture, pushes that container picture to Amazon Elastic Container Registry (ECR), and at last provisions the AgentCore Runtime surroundings that hosts your containerized agent. This eliminates the necessity for guide Dockerfile creation, container builds, or infrastructure administration.

  1. Earlier than you begin this step, ensure you have gone by part 7 and put in the AgentCore CLI and Python dependencies listed within the Stipulations part.
  2. Create a coverage named AgentCoreAccessPolicy with the next permissions and fix it to the function working the code. Substitute and placeholders.
{
  "Model": "2012-10-17",
  "Assertion": [
    {
      "Sid": "BedrockAgentCoreServiceAccess",
      "Effect": "Allow",
      "Action": [
        "bedrock-agentcore:*"
      ],
      "Useful resource": "*"
    },
    {
      "Sid": "ECRAuthorizationToken",
      "Impact": "Enable",
      "Motion": [
        "ecr:GetAuthorizationToken"
      ],
      "Useful resource": "*"
    },
    {
      "Sid": "ECRRepositoryAccess",
      "Impact": "Enable",
      "Motion": [
        "ecr:BatchCheckLayerAvailability",
        "ecr:GetDownloadUrlForLayer",
        "ecr:BatchGetImage",
        "ecr:PutImage",
        "ecr:InitiateLayerUpload",
        "ecr:UploadLayerPart",
        "ecr:CompleteLayerUpload",
        "ecr:DescribeRepositories",
        "ecr:CreateRepository",
        "ecr:ListImages",
        "ecr:DescribeImages"
      ],
      "Useful resource": [
        "arn:aws:ecr:::repository/bedrock-agentcore-*"
      ]
    },
    {
      "Sid": "CodeBuildProjectAccess",
      "Impact": "Enable",
      "Motion": [
        "codebuild:CreateProject",
        "codebuild:UpdateProject",
        "codebuild:StartBuild",
        "codebuild:BatchGetBuilds",
        "codebuild:DeleteProject"
      ],
      "Useful resource": "*"
    },
    {
      "Sid": "IAMRoleManagement",
      "Impact": "Enable",
      "Motion": [
        "iam:CreateRole",
        "iam:AttachRolePolicy",
        "iam:PutRolePolicy",
        "iam:GetRole",
        "iam:GetRolePolicy",
        "iam:PassRole",
        "iam:DeleteRole",
        "iam:DeleteRolePolicy",
        "iam:DetachRolePolicy",
        "iam:CreateServiceLinkedRole"
      ],
      "Useful resource": [
        "arn:aws:iam:::role/BedrockAgentCoreExecutionRole-*",
        "arn:aws:iam:::role/AmazonBedrockAgentCoreSDKCodeBuild-*",
        "arn:aws:iam:::role/aws-service-role/runtime-identity.bedrock-agentcore.amazonaws.com/AWSServiceRoleForBedrockAgentCoreRuntimeIdentity"
      ]
    },
    {
      "Sid": "CloudWatchLogsAccess",
      "Impact": "Enable",
      "Motion": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents",
        "logs:PutResourcePolicy"
      ],
      "Useful resource": "arn:aws:logs:::log-group:/aws/bedrock-agentcore/*"
    },
    {
      "Sid": "CloudWatchLogsResourcePolicy",
      "Impact": "Enable",
      "Motion": [
        "logs:PutResourcePolicy"
      ],
      "Useful resource": "*"
    },
    {
      "Sid": "S3BucketManagement",
      "Impact": "Enable",
      "Motion": [
        "s3:CreateBucket",
        "s3:PutBucketPolicy",
        "s3:PutBucketVersioning",
        "s3:PutBucketPublicAccessBlock",
        "s3:PutLifecycleConfiguration",
        "s3:PutObject",
        "s3:GetObject",
        "s3:ListBucket"
      ],
      "Useful resource": [
        "arn:aws:s3:::bedrock-agentcore-codebuild-sources--*",
        "arn:aws:s3:::bedrock-agentcore-codebuild-sources--*/*"
      ]
    }
  ]
}

  1. Create a file named agentcore.yaml in your challenge listing with the next configuration. Substitute , , and placeholders:
# AgentCore Runtime Configuration
  runtime:
    title: shopping-search-agent-runtime
    entrypoint: search_agent.py:strands_agent_bedrock
    area:   # CHANGE THIS - Your AWS area (e.g., us-east-1)

    execution_role:
      create: true
      title: BedrockAgentCoreExecutionRole-shopping-agent
      insurance policies:
        - policy_name: BedrockAndOpenSearchAccess
          policy_document:
            Model: "2012-10-17"
            Assertion:
              - Sid: BedrockModelAccess
                Impact: Enable
                Motion:
                  - bedrock:InvokeModel
                  - bedrock:InvokeModelWithResponseStream
                Useful resource:
                  - arn:aws:bedrock:*::foundation-model/*
                  - arn:aws:bedrock:::inference-profile/*  # CHANGE THIS - Substitute  and 
              - Sid: OpenSearchAccess
                Impact: Enable
                Motion:
                  - es:ESHttpGet
                  - es:ESHttpPost
                  - es:ESHttpPut
                Useful resource: arn:aws:es:::area//*  # CHANGE THIS - Substitute all three placeholders
              - Sid: CloudWatchLogsAccess
                Impact: Enable
                Motion:
                  - logs:CreateLogGroup
                  - logs:CreateLogStream
                  - logs:PutLogEvents
                Useful resource: arn:aws:logs:::log-group:/aws/bedrock-agentcore/runtimes/*  # CHANGE THIS - Substitute  and 
              - Sid: ECRImageAccess
                Impact: Enable
                Motion:
                  - ecr:GetAuthorizationToken
                  - ecr:BatchGetImage
                  - ecr:GetDownloadUrlForLayer
                Useful resource: "*"

    container:
      structure: arm64  # Choices: arm64 or x86_64
      requirements_file: necessities.txt

    ecr:
      auto_create: true

  1. Run the next command in your terminal to deploy the agent to AgentCore Runtime:
    • Create the AgentCore challenge and substitute together with your search agent.
      agentcore create --name ShoppingAgent --defaults
      cd ShoppingAgent
      cp ../search_agent.py app/ShoppingAgent/predominant.py

    • Add OpenSearch and different dependencies:
      cd app/ShoppingAgent
      uv add opensearch-py requests-aws4auth boto3
      cd ../..

    • Deploy the agent to Agentcore Runtime. This course of takes roughly 5-10 minutes.
    • As soon as deployment completes, confirm the runtime standing:

      You must see:

      ShoppingAgent: Deployed - Runtime: READY (arn:aws:bedrock-agentcore:::runtime/ShoppingAgent_...)
      
      URL: https://bedrock-agentcore..amazonaws.com/runtimes/.../invocations

Step 9: Configure OpenSearch Service entry

Map your AgentCore execution function to an OpenSearch backend function so the agent can entry your information.

  1. Navigate to OpenSearch Dashboards. From the left menu, select the Safety plugin, then select Roles.
  2. Seek for agentcore-permissions and select the function. Then, navigate to the Mapped Customers tab, select Handle mapping, and add arn:aws:iam:::function/AmazonBedrockAgentCoreSDKRuntime-us-east-1-custom as a backend function. Substitute the placeholder together with your account ID.

Animated demo of OpenSearch Dashboards Security plugin showing the agent-permissions role with the Mapped Users tab open and the AgentCore SDK runtime IAM role added as a backend role.

Step 10: Invoke the Bedrock AgentCore Runtime

You’ll be able to check the agent in Agent Sandbox. Enter the immediate Search jacket lower than 50$, and the agent returns the related end result from the OpenSearch Service index with a abstract.

Agent Sandbox console showing a shopping agent response that returns the Mens Cotton Jacket as the relevant result for the prompt “Search jacket less than 50$”.

In real-world situations, you possibly can design a search utility with a Strands Agent deployed in AgentCore Runtime. You’ll be able to add AgentCore Reminiscence, which provides your AI brokers the flexibility to recollect previous interactions and supply extra context-aware, customized conversations.

Cleanup

To keep away from incurring future fees, delete the sources created whereas constructing this answer:

  1. Delete the OpenSearch Service area.
  2. Delete the Amazon Bedrock AgentCore Runtime sources.

Conclusion

On this publish, you noticed create a conversational search with Amazon OpenSearch Service and Strands Brokers. You additionally realized deploy the agent on Amazon Bedrock AgentCore Runtime. You’ll be able to additional improve this buying agent through the use of different AgentCore capabilities. For instance, AgentCore Reminiscence retains consumer preferences and previous interactions throughout periods, AgentCore Id manages shopper authentication and entry management, and AgentCore Observability helps you monitor and debug agent habits in manufacturing. Collectively, these companies allow you to construct buying experiences that ship prompt, related help at scale.

Now it’s your flip. Construct your personal conversational search expertise by integrating OpenSearch Service and Strands Brokers together with your product catalog. To be taught extra, see the Amazon OpenSearch Service and Amazon Bedrock AgentCore element pages.


In regards to the authors

Omama Khurshid

Omama Khurshid

Omama is an GTM Specialist Options Architect Analytics at Amazon Internet Providers. She focuses on serving to clients throughout numerous industries construct dependable, scalable, and environment friendly options. Exterior of labor, she enjoys spending time together with her household, listening to music, and studying new applied sciences.

Jumana Nagaria

Jumana Nagaria

Jumana is a Prototyping Architect at AWS. She builds progressive prototypes with clients to resolve their enterprise challenges. She is enthusiastic about cloud computing and information analytics. Exterior of labor, Jumana enjoys travelling, studying, portray, and spending high quality time with family and friends.

Canberk Keles

Canberk Keles

Canberk is a Options Architect at Amazon Internet Providers, serving to software program corporations obtain their enterprise objectives by leveraging AWS applied sciences. He’s a part of OpenSearch specialist neighborhood inside AWS and has been guiding clients harness the ability of OpenSearch. Exterior of labor, he enjoys sports activities, studying, touring and enjoying video video games.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles