View a markdown version of this page

AgentCore 브라우저 시작하기 - Amazon Bedrock AgentCore

AgentCore 브라우저 시작하기

AgentCore 브라우저를 사용하면 에이전트가 관리형 Chrome 브라우저를 통해 웹 페이지와 상호 작용할 수 있습니다. 이 가이드에서는 5분 이내에 웹 사이트를 탐색하고 정보를 추출하는 AI 에이전트를 생성합니다.

사전 조건

시작하기 전에 다음을 갖추어야 합니다.

IAM 권한

이 정책을 IAM 자격 증명에 연결합니다. IAM 콘솔에서 사용자 또는 역할을 찾고 권한 추가 > 인라인 정책 생성을 선택하고 JSON 보기로 전환한 후 붙여넣습니다.

{ "Version":"2012-10-17", "Statement": [ { "Sid": "BedrockAgentCoreBrowserFullAccess", "Effect": "Allow", "Action": [ "bedrock-agentcore:CreateBrowser", "bedrock-agentcore:ListBrowsers", "bedrock-agentcore:GetBrowser", "bedrock-agentcore:DeleteBrowser", "bedrock-agentcore:StartBrowserSession", "bedrock-agentcore:ListBrowserSessions", "bedrock-agentcore:GetBrowserSession", "bedrock-agentcore:StopBrowserSession", "bedrock-agentcore:UpdateBrowserStream", "bedrock-agentcore:ConnectBrowserAutomationStream", "bedrock-agentcore:ConnectBrowserLiveViewStream" ], "Resource": "arn:aws:bedrock-agentcore:<Region>:++<account_id>++:browser/*" }, { "Sid": "BedrockModelAccess", "Effect": "Allow", "Action": [ "bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream" ], "Resource": [ "*" ] } ] }
참고

<Region>를 실제 AWS 리전으로 바꾸고를 AWS 계정 ID<account_id>로 바꿉니다.

1단계: 종속성 설치

pip install bedrock-agentcore strands-agents strands-agents-tools playwright nest-asyncio

2단계: 에이전트 생성

이름이 browser_agent.py 인 파일을 생성합니다.

참고

를 AWS 리전(예: us-west-2 )<Region>으로 바꿉니다.

from strands import Agent from strands_tools.browser import AgentCoreBrowser # Initialize the Browser tool browser_tool = AgentCoreBrowser(region="<Region>") # Create an agent with the Browser tool agent = Agent(tools=[browser_tool.browser]) # Test the agent with a web search prompt prompt = "what are the services offered by Bedrock AgentCore? Use the documentation link if needed: https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/what-is-bedrock-agentcore.html" print(f"\n\nPrompt: {prompt}\n\n") response = agent(prompt) print("\n\nAgent Response:") print(response.message["content"][0]["text"])

3단계: 에이전트 실행

python browser_agent.py

에이전트가 웹 사이트를 탐색하고 AgentCore 서비스에 대한 세부 정보를 반환하는 것을 볼 수 있습니다. 오류가 발생하면 IAM 권한, 모델 액세스 및 AWS 자격 증명을 확인합니다.

4단계: 브라우저 세션 라이브 보기

에이전트가 실행되는 동안 AWS 콘솔을 통해 실시간으로 볼 수 있습니다.

  1. AgentCore 브라우저 콘솔 열기

  2. 왼쪽 탐색에서 기본 제공 도구로 이동합니다.

  3. 브라우저 도구(예: AgentCore Browser Tool 또는 사용자 지정 브라우저)를 선택합니다.

  4. 브라우저 세션 섹션에서 준비됨 상태의 활성 세션을 찾습니다.

  5. 라이브 보기/레코딩 열에서 제공된 "라이브 세션 보기" URL을 클릭합니다.

라이브 뷰는 자동화에서 제어를 인계하거나 해제할 수 있는 대화형 제어 기능을 갖춘 실시간 비디오 스트림을 제공합니다.

리소스 찾기

AgentCore 브라우저를 사용한 후 AWS 콘솔에서 리소스를 확인합니다.

# Resource Location

1

라이브 뷰

브라우저 콘솔 > 도구 이름 > 라이브 세션 보기

2

세션 레코딩 및 재생

브라우저 콘솔 > 도구 이름 > 레코딩 보기

3

브라우저 로그

CloudWatch > 로그 그룹 > /aws/bedrock-agentcore/browser/

4

파일 기록

S3 > 버킷 > browser-recordings/ 접두사

5

사용자 지정 브라우저

AgentCore 콘솔 > 기본 제공 도구 > 사용자 지정 브라우저

6

IAM 역할

IAM > 역할 > 실행 역할 검색

다음 단계

이제 AgentCore 브라우저가 작동했으므로 다음과 같은 고급 기능을 살펴봅니다.