LangChain、エージェントの決済を仲介する「AgentCore」機能を公開
本文の状態
日本語全文を表示中
詳細モードで約17分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
LangChain Blog
LangChain は AgentCore Payments ミドルウェアを発表し、AI エージェントが安全に支払いを実行できるインフラを提供する。
AI深層分析を開く2026年8月18日 00:22
AI深層分析
キーポイント
ミドルウェアによる決済ロジックの一元化
エージェントが有料 API に直接アクセスできるようになり、決済ロジックを各ツールラッパーではなくミドルウェア層に集約できる。
プロンプト依存ではない支出制限の実装
AgentCore がセッションレベルの予算をインフラ層で強制するため、エージェントがハッキングされた場合でも支出制限は維持される。
LangSmith による監査と評価機能
エージェントが何を購入したかとその理由を LangSmith が記録し、本番環境への展開前に評価テストや事後の精査が可能になる。
x402 プロトコルによるエージェントの取引
Coinbase が作成した x402 プロトコルは、HTTP ネイティブなマイクロペイメントを可能にし、エージェントが安定通貨で支払いながら有料データにアクセスできる仕組みを提供する。従来のカード決済や月額課金とは異なり、秒単位での決済と極小コストにより、1 回ごとの課金が経済的に実現可能になる。
AgentCore Payments の管理機能
AgentCore Payments はウォレット認証から実行、支出ガバナンスまでの支払いライフサイクルを管理し、開発者が支払の複雑さに悩まされることなくエージェントの業務に集中できるようにする。LangChain 開発者は利用課金モデルの実装に注力でき、セキュリティやプロトコルバージョンの管理は同サービスが担う。
重要な引用
Agents can now pay for paid APIs directly, which means payment logic lives in middleware instead of in every tool wrapper you write
The spending limit is enforced by AgentCore rather than by your prompt, which means it holds even if the agent is compromised
The highest-value data, including court filings, real-time market feeds, medical literature, and premium APIs, sits behind paywalls.
Card-processing fees make API calls priced in cents economically impossible.
編集コメントを表示
編集コメント
エージェントが金銭を扱う際の信頼性確保は、実社会での導入における最大の課題の一つであった。インフラ層で予算管理を強制し、かつ LangSmith と連携して透明性を担保するこのアプローチは、開発者が安全に商用サービスを開発するための重要な一歩となる。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
スケールするエージェント型商取引:LangChain エージェントが安全に決済を行う

要点
- エージェントは有料 API の利用料を直接支払えるようになりました。これにより、決済ロジックは各ツールラッパーに記述するのではなく、ミドルウェア側に一元管理されます。
- 支出制限はプロンプトではなく AgentCore が強制するため、仮にエージェントが乗っ取られても制限は維持されます。
- LangSmith は「何を購入したか」とその背後にある推論プロセスを同時に記録します。そのため、事後の精査や本番環境への展開前の評価(evals)による検証が可能になります。
イントロダクション
エージェント経済が目前に迫っています。AI エージェントは無料枠の API を利用する段階から脱却し、プレミアムデータや有料コンテンツ、専門的な計算リソースなど、有償サービスを利用する世界へと移行しています。このエージェント型商取引エコシステムは急速に成長を続けています。
エージェントにお金を使わせる場合、LLM のプロンプト内で制御するのではなく、インフラ層で各取引前に適用されるセッション単位の予算という、確実な支払い制限が必要です。Amazon Bedrock AgentCore Payments は、LangChain 開発者向けに決済専用のインフラを提供し、この課題を解決します。エージェント開発者は、AgentCore Payments のミドルウェア層を追加し、ウォレットを選択して予算を設定するだけでよく、残りの処理はすべて AgentCore Payments が行います。すべての支払いがプロトコル非依存のインフラを経由して流れます。
また、エージェントが何を購入したのか、なぜそれを選んだのかという記録も必要です。その役割を担うのが LangSmith です。本稿では、ビジネス上の必要性、アーキテクチャ、そして導入方法について解説します。
取引を行うエージェント
無料コンテンツしか消費できない自律型エージェントは、完了できるタスクの範囲に限界があります。裁判所の書類、リアルタイム市場データフィード、医療文献、プレミアム API といった高価値なデータの多くは、有料壁の向こう側にあります。最近まで、これらのデータにアクセスするには、手動での API キー管理や、各サービスごとの課金連携が必要でした。あるいは、自律的なワークフローを中断して人間に確認を求める必要さえありました。しかし、この状況は変わりつつあります。
Coinbase が 2025 年 5 月に作成し、現在は Linux Foundation が管理する「x402 プロトコル」により、HTTP ネイティブなマイクロペイメントが可能になりました。このプロトコルを使えば、エージェントは有料エンドポイントにアクセスして価格を確認し、ステーブルコインで支払いを行い、コンテンツを受け取るという一連の処理を、単一の HTTP リクエスト・レスポンスサイクル内で完結させることができます。
アジェンシー(エージェント)取引の性質上、従来の決済経路とは経済構造が異なります。カード決済の手数料がかかる環境では、1 回あたりの API 呼び出しをセント単位で課金するのは経済的に成立しません。また、月額サブスクリプションは「人間が事前に購入を決める」という前提に依存しています。一方、x402 を介したステーブルコインによるマイクロペイメントは、数秒で決済が完了し、1 取引あたりの手数料はセントの何分の一にも抑えられるため、エージェントワークロードにおける 1 回課金モデルの実現を可能にします。
AgentCore Payments は、自律型エージェント向けに設計された管理型の決済機能を提供します。ウォレット認証から取引実行、支出ガバナンスに至るまでのライフサイクル全体をカバーするため、開発者は「エージェントが何をするか」に集中でき、「どのように支払うか」という複雑さから解放されます。LangChain の開発者たちは、今や「従量課金というビジネス課題の解決」そのものに注力できるようになります。AgentCore Payments が担うのは、ウォレットへの安全な接続、決定的な支払い制限の適用、そしてプロトコルのバージョン管理(x402 v1, v2)やその他のマシン間プロトコルに対応する複雑さの排除です。

資金決済には確定的な制限が必要
アクセス権の付与は課題の半分です。エージェントにお金を使わせる場合、以下の重要な問いに答えなければなりません。
- エージェントの使用額をどう制御するか? セッションレベルでの確定的な支払い制限がなければ、無限ループや予期せぬエッジケースが発生した際に資金が枯渇する恐れがあります。
- エージェントの資金源はどう確保するか? Coinbase CDP と Stripe(Privy)との連携により、エンドユーザーはフィアット通貨または USDC ステーブルコインを使って、異なるネットワーク間でコスト効率の高いマイクロトランザクションを行えるようになります。
- どのようにしてエージェントを安全にウォレットに接続するか? AgentCore Payments は、支払いウォレットの認証を安全に行うために AgentCore Identity を利用します。
- どのプロトコルを選ぶべきか? 特定の 1 つのプロトコルに注力するには、それぞれが持つ独自のニュアンスを理解するために多大な時間と労力が必要です。
現在、エージェントを本番環境で運用しているチームのほとんどは、支払い処理を以下の3つの方法のいずれかで対応しています。1つ目は、無料のデータソースにエージェントを誘導する方法です(データ品質は低下しますが、支払い処理が不要になります)。2つ目は、各APIごとにカスタムの支払いロジックを実装する方法で、サービスごとに30〜50行のラッパーコードが必要になります。3つ目は、自律性を放棄して支払いゲートウェイを人間に引き継ぐ方法です。
これらのいずれも、利用する有料サービスの数が数千件に達した際にはスケーラブルではありません。統合の複雑さに加えて、開発者は突発的な支出を防ぐためのガバナンスや予算管理の仕組みをゼロから構築する必要があり、さらに支払いフローが求めるセキュリティ要件や規制遵守基準を満たすことも求められます。
AgentCore Payments の中核となるのは、エージェント開発者の体験です。このソリューションは、開発者がゼロから構築したり、特定のプロトコルに縛られたりすることなく、ウォレットへの接続、プロトコル間での支払いのオーケストレーション、そして支出ガバナンスの実行を可能にします。
「LangChain middleware」は、エージェントの実行ステップごとにフックを公開します。これにより、エージェント自体を変更せずに、モデル呼び出しやツール呼び出しの間に処理を挿入し、独自のロジックを追加することが可能になります。
例えば、法律文書の作成を担当するエージェントがあるとしましょう。その際、裁判所に提出すべき書類が有料の壁(ペイウォール)の向こうにある場合、どうすればよいでしょうか?このエージェントのツールが有料 API を呼び出して HTTP 402 エラーを受け取った瞬間、「AgentCorePaymentsMiddleware」が支払い要件を検知します。そして、セッションごとの予算制限を適用し、Amazon Bedrock AgentCore Payments を介して支払いを実行した上で、支払い認証情報を用いてリクエストを再試行します。
その結果、エージェントはあなたが設定した範囲内で、求めたデータを入手できます。詳細についてはドキュメントをご覧ください。

仕組み
- 検出: ツールが有料 API を呼び出し、HTTP 402 エラーと x402 ペイロードを含むレスポンスを受け取ります。
- 検証: ミドルウェアが支払い金額をセッションの予算枠と比較します。上限を超えている場合はリクエストを拒否し、支払い署名は行われません。
- 署名: 予算範囲内であれば、AgentCore PaymentManager を介して支払いに署名します。
- 再試行: 元のリクエストに支払い証明を添付して再実行されます。すると API はコンテンツを返却します。
- 継続: エージェントは、あたかも初回の呼び出しで HTTP 200 が返されたかのようにコンテンツを受け取ります。
セットアップには設定オブジェクトと、ミドルウェアリストへのエントリーが 1 つ必要です:
__FENCE_0__
この仕組みは LangChain エージェントがサポートするあらゆるモデルプロバイダーで動作しますが、支払いインフラストラクチャ自体には AgentCore の利用が必要です。
適用シーン
AgentCore Payments ミドルウェア は、エージェントが複数の有料サービスにアクセスする必要があるワークロードにおいて、予算を厳格に管理しながら利用する場合に特に適しています。
| ユースケース | 機能する理由 |
|---|---|
| 研究用エージェント | プレミアムデータベースへのアクセス:法廷記録、医学文献、金融データ |
| 多段階ワークフロー | 複数の有料サービスに順次アクセスしつつ、総予算内で動作するディープエージェント |
| ユーザーごとの支出管理 | 各エンドユーザーに独自の予算と決済手段を割り当てる SaaS プロダクト |
| MCP サーバーの消費量管理 | MCP ツールは、402 ステータスをテキストコンテンツとして返し、headers 引数を転送することで自動決済と連携可能 |
| ブラウザエージェント | 有料コンテンツの壁を突破し、多数のサイトから情報を抽出する |
エージェントの支出を監査する
エージェントにコスト制限を追加しても、過剰な支出を防ぐことはできても、その取引に至った根本的な行動自体を変えるわけではありません。この問題は、いくつかの形で現れます。
- エージェントは予算内に収まっているが、何をすべきかの判断が不適切である
- エージェントは数ステップで予算を使い果たし、タスクに失敗する
- 有料リクエストに、システムから流出させるべきではないデータが含まれている
- 悪意のあるツールの説明によって、誰も求めていないエンドポイントへ誘導される
これら4つのケースはいずれも、完了し、予算内に収まり、請求書上では問題ないように見えます。その理由は、ブロックチェーンの支払い台帳が記録しているのは「ツール X が 14:03:11 にアドレス Y へ $0.02 を送金した」という事実だけだからです。エージェントが研究タスクの 3 ステージ目にあり、1 ドルという制限の中で、ツールの説明に裁判所の書類に関する記述があったためにそのエンドポイントを選んだという文脈は記録されていません。そのような背景情報は、エージェントのトレース(追跡ログ)の中だけに存在します。
私たちは、この情報が以下の2つの点で重要だと考えています。ガバナンス(意図しないエージェント支出の防止)と監査(数ヶ月後でも誰かが照会できる、エージェントが何を購入したかの永続的な記録)です。
組織内における他の支出と同様、エージェントの支出についても「誰が承認したのか」「上限はいくらか」「その上限が実際に守られたかどうかがどうやって確認できるのか」といった質問が投げかけられることになります。
もしすでに LangSmith でエージェントを追跡しているなら、各ステップをたどって支払いに至るまでの過程を確認できます。ツール呼び出しが行われ、402 エラーが返された後、ユーザーの元のリクエストとモデルの推論に挟まれながら、支払いヘッダーが付加された形で再度表示されます。

短いレコーダーミドルウェアは、支払いが成功した場合に、金額、ネットワーク、受取人、トリガーしたツール、そして請求先のセッションとユーザーといった詳細をメタデータとして付加します。

支払いが予算を超えそうになると、AgentCore はそれを拒否します。その拒否の記録はエージェントからの回答とともにトレースに表示されるため、上限が守られたと推測するのではなく、実際に守られたことを確認できます。

拒否の記録は「発生した事実」を残すものであり、支払いが行われなかったため金額の詳細は含まれません。正確な数値は AgentCore のログに保存されています。
本番の資金を使う前にテストする
トレース(追跡ログ)からは、エージェントが購入リクエストに対してどのように推論したかがわかります。一方、評価(evals)では、その購入リクエスト背后的な思考が意図通りだったかを確認し、適切な動作を検証するとともに、エージェントのミスを修正すべき箇所を特定できます。
- シングルステップ評価は、1 つの意思決定のみをテストします。ペニー単位のタスクを与え、50 ドルを要求する 402 エラーを返させた上で、それでも支払いを実行してしまうかどうかを確認します。
- フルターン評価では、データセット全体を通じて会話の軌跡をスコアリングし、総支出額、実行された有料呼び出しの数、タスク完了状況を総合的にチェックします。エージェントが過剰な購入を開始しても完璧な回答を返す可能性があるため、プロンプトやツールセットの変更ごとに必ず実行する必要があります。
- オンライン評価は、LangSmith 上の本番環境のトレースに対して同じチェックを実行し、支出閾値を超えた実行や、予期しないエンドポイントへの支払いを検出します。
以下にフルターンの例を示します。10 の研究タスクがあり、それぞれがエンドポイントの請求額を賄える予算を持っています。各実行は 2 つの評価者がスコアリングします。spend_within_budget は、実際に支払われた金額とタスクの予算を比較します。relevant_data は、エージェントが購入したデータが与えられた質問に答えているかどうかを確認します。

今回の実行では、10 件のタスクすべてで支出が予算内に収まり、7 件については関連性のあるデータが得られました。残る 3 件では、エージェントが回答不能な問いに対して支払いを行ってしまいました。
データセット、評価指標、そして実験を組み合わせることで、「エージェントがお金を使ったか」だけでなく「その支出が有用な成果につながったか」という視点が得られます。プロンプトやモデル、予算を変更して同じ 10 件のタスクを再実行すれば、新しいバージョンと今回の結果を比較できます。比較項目にはレイテンシ、トークン数、そしてモデルコストも含まれます。
はじめに
AWS 側でのセットアップには 2 つの方法があります。AgentCore Payments スキルを使えば、Claude Code、Kiro、または Codex との対話を通じて PaymentManager と支払い手段をセットアップできます。あるいは、AgentCore CLI、AWS SDK、Boto3 を使って手動で設定することも可能です。
その後、ミドルウェアをインストールします:
__FENCE_1__
LangChain を利用している場合でも、strands-agents のインストールは必須です。統合パッケージには LangChain と Strands の両方のアダプターが含まれており、これを省略するとインポートエラーが発生するためです。
セッション予算を小さめに設定し、LangSmith のトレーシング機能を有効にした状態で、一度有料タスクを実行してください。その結果のトレース情報から「コストはいくらか、そしてなぜそうなるのか」を説明できるのであれば、セットアップは成功です。
そこから先は、LangSmith 上で小規模な評価用データセットを作成し、予算閾値を超えた実行を自動的に検知するオンラインルールを追加しましょう。
すぐに始められるためのリソース:
- AgentCore Payments ミドルウェアのドキュメント
- AWS 上の AgentCore Payments
- LangSmith のトレーシングと評価機能を実装したサンプルエージェント
- AgentCore Payments のコードサンプル
- LangSmith の無料体験 または デモのリクエスト
- AWS マーケットプレイスでの LangSmith
「エージェントは、単に回答を生成するシステムから、行動を起こすシステムへと進化しています。そしてその行動には、経済取引が伴うケースも増えています。これは、開発者がエージェント周辺インフラに求めるものを根本的に変えます。開発者は、エージェントの振る舞いを評価し、意思決定を理解し、境界線を明確にする必要があります。LangSmith と Amazon Bedrock AgentCore Payments は、この課題の異なる側面を補完し合うソリューションを提供します。これにより、開発者は、より高い自律性で動作しつつも、監視可能かつ制御された状態を保つエージェントを構築できるようになります。」
— ハーソン・チェイス氏、LangChain CEO 兼共同創設者
「AgentCore と LangChain のチームが AgentCore Payments Middleware で手を組んだことを嬉しく思います。開発者が LangChain エージェントに対して、安全かつ決定論的なガードレールの中でサービスやコンテンツの支払いを可能にするシンプルな手段を提供することで、我々は全く新しいクラスの自律型エージェント体験を開花させるのです。この機能を使って何を作るのか、今から楽しみです。」
— プリティ・CN 氏、Amazon Bedrock AgentCore ディレクター
関連記事

パートナー
エージェントの呼び出しのうち、実際に最先端モデルが必要なのはどれくらいか?


S. Tangedipalli,
K. Singh
2026 年 8 月 11 日
11 分
.png)
パートナー
金融サービス分野におけるエージェント型AIのROIを実証する


K. シンガー、
D. テッパー
2026年7月17日
14 分

ケーススタディ
パートナー
モデルではなくハネスを調整する:Nemotron 3 Ultra の運用プレイブック


N. ホロン、
S. タンゲディパッリ
2026年7月8日
11 分
エージェントが実際に何をしているかを確認する
LangSmith は、エージェントエンジニアリングを支援するプラットフォームです。開発者はこれを使って、すべてのエージェントの意思決定をデバッグし、変更の評価を行い、ワンクリックでデプロイできます。
原文を表示
Agentic Commerce at Scale: Your LangChain agents can transact securely

要点
- Agents can now pay for paid APIs directly, which means payment logic lives in middleware instead of in every tool wrapper you write
- The spending limit is enforced by AgentCore rather than by your prompt, which means it holds even if the agent is compromised
- Because LangSmith captures what an agent bought alongside the reasoning behind it, you can audit spending after the fact and test it with evals before it goes live
はじめに
The agentic economy is imminent. AI agents are moving past free-tier APIs into a world of paid services: premium data, paid content, specialized compute. The agentic commerce ecosystem is growing fast.
When an agent can spend money, you need deterministic payment limits: session-level budgets enforced before every transaction at an infrastructure layer, not in LLM prompts. Amazon Bedrock AgentCore Payments solves this for LangChain developers with purpose-built infrastructure for payments. As an agent developer you add the AgentCore Payments middleware layer, choose your wallet, set up a budget, and AgentCore Payments handles the rest. Every payment flows through the protocol-agnostic infrastructure.
You also need a record of what the agent bought and why it picked that, which is where LangSmith comes in. This post explains the business case, the architecture, and how to get started.
Agents that transact
Autonomous agents that can only consume free content are limited in what kinds of jobs they can complete. The highest-value data, including court filings, real-time market feeds, medical literature, and premium APIs, sits behind paywalls. Until recently, accessing this data required manual API key management, per-service billing integrations, or breaking the autonomous workflow to ask a human. This is changing.
The x402 protocol, created by Coinbase in May 2025 and now stewarded under the Linux Foundation, makes HTTP-native micropayments possible. Using x402, an agent hits a paid endpoint, receives a price, pays in stablecoins, and gets the content, all within a single HTTP request-response cycle.
The economics work differently from traditional payment rails due to the nature of agentic transactions. Card-processing fees make API calls priced in cents economically impossible. Monthly subscriptions assume a human deciding what to buy in advance. Stablecoin micropayments via x402 settle in seconds at fractions of a cent per transaction, making per-call pricing viable for agent workloads.
AgentCore Payments provides managed payment capabilities purpose-built for autonomous agents, spanning the full lifecycle from wallet authentication through transaction execution to spending governance, so developers can focus on what their agents do, not on how they pay. LangChain developers can now focus on the pay-per-use business problem they are solving, while AgentCore Payments takes away the complexity of securely connecting to wallets, enforcing deterministic payment limits, and managing different versions of the protocol (x402 v1, v2) or other machine-to-machine protocols.

Spending money needs deterministic limits
Access is only half of the challenge. When agents can spend money, you need answers to hard questions:
- How do I control the agent spend? Without session-level deterministic payment limits, a runaway loop or unexpected edge case could drain funds.
- How do I fund my agent? With Coinbase CDP and Stripe (Privy) integration, end users can fund their wallets through fiat or USDC stablecoin across different networks for cost-effective microtransactions.
- How does my agent connect to the wallet securely? AgentCore Payments uses AgentCore Identity for secure authentication of payment wallets.
- Which protocol do I pick? Ramping up on any single protocol demands significant time and effort, as each comes with its own nuances.
Today, most teams that productionize their agent handle agent payments in one of three ways: they point the agent at a free source instead (worse data, but no payment to handle), they build custom payment logic per API (30 to 50 lines of wrapper code per service), or they give up autonomy (the agent surfaces the paywall to a human). None of these scale as the number of paid services grows into the thousands. Beyond integration complexity, developers must build governance and budget guardrails from scratch to help prevent runaway spending, and meet the security and regulatory compliance requirements that payment flows demand.
Agent developer experience is the cornerstone of AgentCore Payments. It gives developers one solution that connects to wallets, orchestrates payments across protocols, and enforces spending governance, without having to build it from scratch or commit to a protocol to get started.
LangChain middleware exposes hooks at each step of an agent's execution, so you can intercept a model call or a tool call and add logic without changing the agent itself. Say you have a legal agent drafting a brief, and the court filing it needs sits behind a paywall. When its tool hits that paid API and gets back an HTTP 402, AgentCorePaymentsMiddleware detects the payment requirement, enforces session budget limits, signs the payment via Amazon Bedrock AgentCore Payments, and retries the request with payment credentials. Your agent gets the data it asked for, within the limits you set. Read more in the documentation.

How it works
- Detect. A tool hits a paid API that returns HTTP 402 with an x402 payload.
- Validate. The middleware checks the payment amount against your session budget. If it exceeds the limit, the request is rejected and no payment is signed.
- Sign. If within budget, the middleware signs the payment via AgentCore PaymentManager.
- Retry. The original request is retried with payment proof attached. The API returns the content.
- Continue. The agent receives the content as if the API returned 200 on the first try.
Setup is a config object and one entry in your middleware list:
config = AgentCorePaymentsConfig(
payment_manager_arn="arn:aws:bedrock-agentcore:us-east-1:...:payment-manager/pm-abc123",
user_id="user-123",
payment_instrument_id="instrument-456",
region="us-east-1",
auto_session=True, # session created on the first 402
auto_session_budget="5.00", # hard ceiling for this session
)
agent = create_agent(
model=model,
tools=[], # the middleware registers http_request and payment query tools
middleware=[AgentCorePaymentsMiddleware(config)],
)
It works with any model provider LangChain agents support, though you'll need AgentCore for the payment infrastructure itself.
Where it fits
The AgentCore Payments middleware is a strong fit for workloads where agents need to access multiple paid services within controlled budgets.
| Use Case | Why It Works |
|---|---|
| Research agents | Access premium databases: legal filings, medical literature, financial data |
| Multi-step workflows | Deep agents that access multiple paid services in sequence while staying under a total budget |
| Per-user spending control | SaaS products where each end user has their own budget and payment instrument |
| MCP server consumption | MCP tools can work with auto-payment when they return the 402 as text content and forward a headers argument |
| Browser agents | Navigate paywalled websites to extract content from many sites |
Auditing what your agents spend
Adding cost controls to an agent limits cost overruns, but it doesn't impact the agent behavior that led to those transactions in the first place. This can show up in several ways:
- An agent stays under budget but reasons poorly about what to buy
- An agent spends its whole allowance in two steps, then fails the task
- An agent's paid request carries data that shouldn't leave your systems
- An agent is redirected by a malicious tool description to an endpoint nobody asked for
All four can finish successfully, come in under budget, and look reasonable on an invoice. That's because the blockchain payments ledger only records that instrument X sent $0.02 to address Y at 14:03:11. It doesn't record that the agent was three steps into a research task, had a one-dollar limit, and chose that endpoint because a tool description mentioned court filings. That context exists only in the agent trace.
We think that matters for two things: governance, avoiding unintended agent spending; and audit, meaning a durable record of what your agents bought that someone can query months later.
Agent spending will get the same questions as any other spend within an organization. Who authorized it? What was the limit? How do you know the limit held? If you already trace your agents in LangSmith, you can track each step that led to an agent payment. The tool call appears, returns a 402, and appears again with a payment header attached, surrounded by the user's original request and the model's reasoning at each step.

A short recorder middleware attaches the payment details as metadata on successful payments: amount, network, recipient, the tool that triggered it, and the session and user it was charged to.

When a payment would exceed the budget, AgentCore denies it. The refusal shows up in the trace alongside the agent's response to it, so you can confirm the limit held rather than assuming it did.

A refusal records that it happened, not what it cost, since the payment was never made. The exact figures stay in AgentCore's logs.
Testing spend before it's real money
Traces tell us how the agent reasoned through the purchase request. Evals test whether the thinking behind the purchase request was as intended so that you can validate good behavior and identify fixes for agent mistakes.
- Single-step evals test one decision. Give the agent a task worth pennies, return a 402 asking for fifty dollars, and check whether it pays anyway.
- Full-turn evals score the conversation trajectory across a dataset, checking total spend, number of paid calls, and task completion together. You will want to run them on every prompt or toolset change, since an agent that starts buying more than it needs still returns a perfectly good answer.
- Online evals run the same checks against production traces in LangSmith, flagging runs over a spend threshold or payments to unexpected endpoints.
Here is a full-turn example: ten research tasks, each with a budget that covers what the endpoint charges. Two evaluators score every run. spend_within_budget compares what the run actually paid against the task's budget. relevant_data checks whether the data the agent bought answers the question it was given.

For this run, spending stayed inside the budget on all ten tasks, and the data was relevant on seven. On the other three the agent paid for a response that could not answer the question.
A dataset, evaluators, and an experiment together give you that view: not just whether the agent spent, but whether the spending bought anything useful. Change a prompt, a model, or a budget, rerun the same ten tasks, and you can compare the new version against this one, including latency, tokens, and model cost.
Getting started
Two ways to provision this on the AWS side. The AgentCore Payments skill sets up your PaymentManager and payment instrument through a guided conversation with Claude Code, Kiro, or Codex, or you can do it by yourself with the AgentCore CLI, AWS SDK, or Boto3. Then install the middleware:
pip install -U "bedrock-agentcore[langgraph,strands-agents]"
Include strands-agents even though you're on LangChain. The integrations package imports both the LangChain and Strands adapters, so the import fails without it.
Add the middleware with a small session budget, turn on LangSmith tracing, and run one paid task. If you can answer "what did this cost and why" from the trace alone, you're set up correctly. From there, build a small eval dataset on LangSmith and add an online rule that flags runs over your threshold.
Everything you need to get going:
- AgentCore Payments middleware docs
- AgentCore Payments on AWS
- Sample agent with LangSmith tracing and evals
- AgentCore Payments code samples
- Try LangSmith or get a demo
- LangSmith on AWS Marketplace
"Agents are evolving from systems that generate answers into systems that take action—and increasingly, some of those actions will involve economic transactions. That changes what developers need from the infrastructure around agents. They need to evaluate behavior, understand decisions, and enforce boundaries. LangSmith and Amazon Bedrock AgentCore Payments address complementary parts of that challenge, helping developers build agents that can operate with greater autonomy while remaining observable and controlled."- Harrison Chase, CEO and Co-Founder, LangChain
"Thrilled to see the AgentCore and LangChain teams come together on AgentCore Payments Middleware. By giving developers a simple way to enable their LangChain agents to pay for services and content, safely, with deterministic guardrails, we're unlocking an entirely new class of autonomous agent experiences. Can't wait to see what builders create with this."- Preethi CN, Director, Amazon Bedrock AgentCore
Related content

Partner
How many of your agent's calls actually need a frontier model?


S. Tangedipalli,
K. Singh
August 11, 2026
11
min
.png)
Partner
Proving the ROI of agentic AI in financial services


K. Singh,
D. Tepper
July 17, 2026
14
min

Case Studies
Partner
Tuning the harness, not the model: a Nemotron 3 Ultra playbook


N. Hollon,
S. Tangedipalli
July 8, 2026
11
min
See what your agent is really doing
LangSmith, our agent engineering platform, helps developers debug every agent decision, eval changes, and deploy in one click.
関連記事
今日のまとめ
AIデイリーブリーフで今日の重要ニュースをまとめ読み