跳到正文
DEV Community· Vaibhav Shakya·· 4 小時前AI 評分54

自主 AI 智能體付款架構:以權限委派控制資金操作

When Software Gets a Wallet: Architecting Payments for Autonomous AI Agents

AI 導讀

文章主張,自主 AI 智能體應提出付款請求,由獨立政策檢查和支付系統決定是否授權,而非直接掌握支付憑證或不受限制的資金。權限可按金額、商戶、用途和有效期收窄;提示詞注入應由獨立政策把關,支付逾時則需以冪等語義避免重複扣款,並由後端保存權威交易紀錄。

正文

AI agents are moving from recommendation systems toward systems that can actually take actions.

That becomes much more serious when the action involves money.

An autonomous agent may discover a product, compare alternatives, select a merchant, and initiate a purchase without a human being present at the exact moment payment happens.

At that point, the problem is no longer simply:

How do we let an AI agent pay?

The better question is:

How do we let probabilistic software request economic actions while deterministic systems retain authority over what is actually allowed?

The Problem

The dangerous design is to treat an AI agent like a human user with a wallet.

Giving the model direct access to card numbers, private keys, bank credentials, or unrestricted wallet balances creates an unnecessarily large privilege boundary.

A safer architecture separates responsibilities:

User or business intent
        ↓
AI agent reasoning
        ↓
Structured payment request
        ↓
Policy and risk checks
        ↓
Bounded payment capability
        ↓
Payment infrastructure
        ↓
Merchant
        ↓
Ledger and reconciliation

The model may decide that a purchase is useful.

It should not automatically possess the authority required to execute that purchase.

Where It Gets Difficult

Several problems become significantly more important once agents can initiate payments.

1. Prompt injection becomes a financial-control problem

An agent may read webpages, emails, PDFs, API responses, or merchant descriptions before deciding what action to take.

Any of those inputs could contain misleading or adversarial instructions.

If the same model can both interpret that content and freely spend money, a content-security failure can become a financial loss.

The stronger control is not simply making the model harder to manipulate.

The stronger control is ensuring that even a manipulated model still has to pass an independent payment policy.

2. A timeout does not mean the payment failed

Imagine the agent submits a purchase.

The payment succeeds, but the network response is lost.

The agent sees a timeout.

A naive autonomous system may reason:

No response → probably failed → try again

That can create duplicate charges.

Payment infrastructure therefore needs stable business identifiers and idempotency semantics so that multiple execution attempts can still represent one economic action.

3. Agent memory cannot become the financial ledger

An AI agent may have conversation history, long-term memory, retrieval systems, or stored context.

None of those should be the authoritative source of financial truth.

The backend needs durable records of:

  • Which user or organization authorized the action
  • Which agent initiated it
  • What permission existed
  • Which policy evaluated it
  • What amount was requested
  • What actually succeeded
  • What retries occurred
  • Whether approval was required
  • What was ultimately delivered or refunded

The model's explanation can be useful context.

It should not replace the transaction record.

Architectural Direction

The core design principle is delegated authority.

Instead of giving an agent general permission to "make payments," grant narrowly scoped capabilities.

For example:

Agent A may spend up to ₹5,000
at SOFTWARE merchants
for PROJECT-42
until 18:00 UTC
with a maximum of one transaction.

That is very different from:

Agent A may make payments.

Useful constraints can include:

  • Maximum amount
  • Cumulative budget
  • Merchant or merchant category
  • Product or SKU
  • Currency
  • Validity period
  • Transaction count
  • One-time versus recurring payment
  • Human approval requirements

Not every payment rail supports every restriction directly.

Some constraints may be enforced by the agent platform, some by a backend policy engine, and others by the PSP, payment network, wallet, or merchant.

The important part is that the rules are deterministic and independently enforced.

Human Intent Should Be Durable

Suppose a user tells an agent:

Book me a nonstop flight to Bengaluru next Friday evening for less than ₹9,000.

The payment may happen hours later.

The conversation itself should not be the only proof of authorization.

A stronger system converts that instruction into a durable mandate containing constraints such as:

{
  "action": "purchase_flight",
  "destination": "BLR",
  "departure_after": "18:00",
  "max_amount_minor": 900000,
  "currency": "INR",
  "nonstop_only": true
}

When the agent later finds a flight, the payment system compares the proposed transaction against that stored authority.

The key audit question becomes:

What had the user actually authorized when this transaction executed?

rather than:

What did the model think the user wanted?

Payment State Still Belongs to the Backend

Agents do not remove normal distributed-systems problems.

They make some of them more dangerous.

A payment may move through states such as:

REQUESTED
POLICY_APPROVED
PAYMENT_AUTHORIZED
CAPTURE_PENDING
CAPTURED
FULFILLED

It may also reach states such as:

POLICY_REJECTED
REQUIRES_HUMAN_APPROVAL
PAYMENT_UNKNOWN
CAPTURE_FAILED
REFUNDED
REVERSED

These exact states vary by payment provider and payment rail.

The architectural point is that payment state must be explicit and authoritative.

The agent should not infer financial truth from conversational tool responses.

The Takeaway

The interesting part of an "AI wallet" is not the wallet.

It is the delegation architecture around it.

A trustworthy system needs to establish something equivalent to:

I am Agent X.
I am acting for Principal Y.
Principal Y authorized action Z.
That authority is valid under conditions C.
This requested transaction satisfies those conditions.

The payment infrastructure then independently decides whether those claims are sufficient to allow money movement.

The AI may discover the opportunity and request the purchase.

But identity, policy, scoped authority, transaction state, idempotency, auditability, and reconciliation are what make autonomous payments viable as financial infrastructure.

Want the deeper architectural breakdown, implementation considerations, failure scenarios, and full reasoning?

Read the full article on Medium

Follow my work

I write about software architecture, FinTech, AI, cybersecurity, distributed systems, mobile engineering, and production engineering.

Connect with me on LinkedIn

Explore more at vaibhavshakya.com

#AgenticAI #FinTech #SoftwareArchitecture #Payments

來源:DEV Community · dev.to