AWS Machine Learning1h agoenergy 123

Building agents that transact with Anchor Browser and AgentCore payments

image: AWS Machine Learning

AI agents increasingly need to access web resources that are priced per request. For example, premium datasets charge by the query, research APIs meter by the call, and paywalled publishers gate content behind payment. When an AI agent encounters one of these resources, the server returns HTTP 402 Payment Required. The agent has no built-in payment mechanism, no budget attached to the session, and no programmatic way to satisfy the request. The task stalls and requires manual intervention. Anchor Browser with Agentic Payments handles machine-to-machine payment workflows on behalf of the agent. Developed in collaboration with the AWS Generative AI Innovation Center Partner Agent Factory , it’s now available on AWS Marketplace . This post covers how Anchor Browser integrates with Amazon Bedrock AgentCore payments so that AI agents can pay for x402-protected pages and APIs autonomously. The x402 protocol is an open standard for HTTP-based machine-to-machine payments. A server responds with 402 Payment Required along with the amount, accepted payment methods, and payment address that the agent uses to complete the transaction. Anchor Browser is a cloud-based browser automation solution purpose-built for AI agents. Each agent session runs inside a managed browser environment that maintains authentication state, handles navigation, captures network requests, and provides a live view of page interactions. Amazon Bedrock AgentCore provides capabilities to build, connect, and optimize agents at scale. Amazon Bedrock AgentCore payments is a fully managed capability within AgentCore that AI agents can use to discover, access, and pay for APIs, Model Context Protocol (MCP) servers, and web content autonomously. AgentCore payments manages wallet connectivity, enforces configurable spending limits at the infrastructure layer, and processes payments through the x402 protocol. It also provides observability into payment attempts, approvals, denials, and settlements through Amazon CloudWatch. When an agent running in Anchor Browser encounters a 402 response, AgentCore payments authorizes and completes the transaction within the configured budget. The workflow continues without interruption. Challenges When an autonomous agent encounters an x402-protected resource, the workflow stalls. The agent makes a request, such as fetching a premium research report or calling a paid data enrichment API, and the server responds with HTTP 402 Payment Required. Without a mechanism to pay, the task that was supposed to run autonomously now requires human intervention. Today, developers must build the entire payment stack. This effort spans four categories of complexity: Payment protocol handling Detecting and parsing the 402 challenge from the HTTP response, and distinguishing payment-required responses from other 4xx errors. Constructing the correct payment header with the cryptographic proof in the exact format the merchant expects. Supporting multiple payment schemes (exact, upto, and protocol variants) without hardcoding vendor-specific logic into the agent. Maintaining compatibility across x402 merchant implementations that might vary in challenge format, supported stablecoins, or settlement timing. Security and key management Storing a private key to sign payments, requiring secure key storage within an environment exposed to untrusted inputs. Managing wallet lifecycle operations, including key rotation, credential refresh, and provider failover. Operational resilience Resubmitting the original request with the payment header while preserving session state, cookies, and request context. Providing idempotency, which is essential for wallet operations. Enforcing per-session and per-transaction spend limits with real-time budget tracking across concurrent agent executions. Observability and compliance Capturing every payment attempt, approval, denial, and settlement in audit logs for compliance and reconciliation. Without a managed payment service, the agent must internalize the entire payment stack. On every x402-protected call that returns a 402 response, the agent must orchestrate the full payment flow internally, including: Signing the proof. Attaching the correct header. Retrying the request. Settling the transaction. Logging the result. Each of these steps requires custom code that developers must build, secure, and maintain. Figure 1 illustrates this architecture. The agent contains eight tightly coupled components (Wallet, Private Keys, Budget Controls, Sign Proof, Attach Header, Retry Logic, Settle Payment, and Logging). The agent connects to an x402 API with a 402 challenge flowing back and a retry flowing forward. Figure 1: Agent payment stack The security considerations extend beyond the engineering effort. Uncontrolled spending. Without hard spending limits enforced at the infrastructure level, a bug, retry loop, prompt injection, or inadvertent access can trigger unintended payments. An agent retrying a paid endpoint in a loop continues to authorize payments until manual intervention occurs. Key exposure. When private keys reside inside the agent runtime, they share an execution environment with untrusted web pages, third-party tools, and external dependencies. These vectors might inadvertently disclose the credentials that control real funds. Signing flow exposure. If the signing infrastructure is accessible from the runtime, a threat actor can attempt to access the key or redirect payments to an address under unauthorized control. Effective mitigation requires that the key doesn’t enter the runtime in the first place. Browser-based agents introduce an additional constraint: the payment must occur within the same browser session. Otherwise, session recordings and live view no longer match what actually executed. Solution Anchor Browser and AgentCore payments address this complexity by moving the entire payment stack into managed infrastructure. Unlike a stateless tool call, Anchor Browser provides a real cloud browser with persistent identity, repeatable and deterministic workflows, and the session context needed to log in, navigate, and finish tasks reliably. Authentication, navigation, network requests, recordings, and live view happen inside the same browser session. When a payment is required, the transaction happens within that session. The recording captures the full sequence from request to 402 to payment to content delivery. Anchor agents include a built-in x402 tool that handles paid API calls natively within the browser context. The built-in tool requires no changes to existing Playwright, Puppeteer, or Chrome DevTools Protocol-based workflows. AgentCore payments serves as the payment layer. At the center of the service is the Payment Manager, the top-level resource that coordinates payment operations for the AWS account. Creating a Payment Manager requires specifying an authorizer type and an IAM role. AgentCore then provisions a corresponding workload identity in Amazon Bedrock AgentCore Identity. The remaining components connect the Payment Manager to external wallet infrastructure: A PaymentConnector integrates the Payment Manager with an external wallet provider, either Coinbase Developer Platform (Coinbase CDP) or Stripe Privy. A PaymentCredentialProvider stores wallet provider credentials securely in AgentCore Identity. A PaymentInstrument identifies the specific wallet address from which funds are drawn. Anchor Browser sets up wallets through AgentCore payments using a supported wallet provider, without placing wallet secrets or private keys inside the agent runtime. AgentCore payments handles wallet operations through the configured provider. For endpoint discovery, AgentCore provides a curated Coinbase x402 Bazaar MCP server through Amazon Bedrock AgentCore Gateway , so agents can discover available pay-per-use x402 endpoints programmatically. AgentCore payments restructures the payment architecture. Sensitive operations move out of the agent

read the original at AWS Machine Learning →