AgentCore#

AWS Bedrock AgentCore 提供带 SigV4 认证的云浏览器会话。当你在 AWS 环境中运行 agent-browser,或者需要由 AWS 基础设施托管的云浏览器时,可以使用它。

设置#

Credentials are automatically resolved from:

  1. Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
  2. AWS CLI (aws configure export-credentials) which supports SSO, profiles, IAM roles, etc.
bash
agent-browser -p agentcore open https://example.com

Or use environment variables for CI/scripts:

bash
export AGENT_BROWSER_PROVIDER=agentcore
agent-browser open https://example.com

The -p flag takes precedence over AGENT_BROWSER_PROVIDER.

配置#

VariableDescriptionDefault
AGENTCORE_REGIONAWS region for the AgentCore endpointus-east-1
AGENTCORE_BROWSER_IDBrowser identifieraws.browser.v1
AGENTCORE_PROFILE_IDBrowser profile for persistent state (cookies, localStorage)(none)
AGENTCORE_SESSION_TIMEOUTSession timeout in seconds3600
AWS_PROFILEAWS CLI profile for credential resolutiondefault
AWS_ACCESS_KEY_IDAWS access key (checked before AWS CLI fallback)(none)
AWS_SECRET_ACCESS_KEYAWS secret key(none)
AWS_SESSION_TOKENTemporary session token (for STS/SSO credentials)(none)

浏览器配置文件#

使用 AGENTCORE_PROFILE_ID 可在会话之间持久保存浏览器状态(cookies、localStorage):

bash
AGENTCORE_PROFILE_ID=my-profile agent-browser -p agentcore open https://example.com

When a profile is set, AgentCore stores and restores browser state automatically between sessions.

实时视图#

When a session starts, AgentCore prints a Live View URL to stderr:

bash
Session: abc123-def456
Live View: https://us-east-1.console.aws.amazon.com/bedrock-agentcore/browser/aws.browser.v1/session/abc123-def456#

在浏览器中打开此 URL,即可从 AWS Console 实时观看代理会话。

凭据解析#

AgentCore uses lightweight manual SigV4 signing (no AWS SDK dependency). Credentials are resolved in order:

  1. Environment variables (AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY, optionally AWS_SESSION_TOKEN)
  2. AWS CLI (aws configure export-credentials --format env), which supports SSO, IAM roles, credential files, and profiles

If using SSO, run aws sso login before launching agent-browser. Set AWS_PROFILE to select a specific named profile.

示例#

bash
# Basic usage (credentials auto-resolved via AWS CLI)
agent-browser -p agentcore open https://example.com

# With a browser profile for persistent login state
AGENTCORE_PROFILE_ID=my-profile agent-browser -p agentcore open https://x.com/home

# With explicit region
AGENTCORE_REGION=eu-west-1 agent-browser -p agentcore open https://example.com

# With SSO profile
AWS_PROFILE=my-sso-profile agent-browser -p agentcore open https://example.com

启用后,agent-browser 会连接到 AgentCore 云浏览器会话,而不是启动本地浏览器。所有命令的行为都相同。