How to Enforce Spending Limits Before an AI Agent Signs a Payment

Nov 30, 2026

Share

Category /

other

11 min read

GOAT Network

How to Enforce Spending Limits Before an AI Agent Signs a Payment

Use an application budget, AgentKit action policy, and signer checks to stop over-limit or redirected agent payments before a signature is requested.

scroll

Table of contents

Use an application budget, AgentKit action policy, and signer checks to stop over-limit or redirected agent payments before a signature is requested.

An AI agent has permission to spend 1.20 USDC per data purchase and 3.00 USDC across a research job. It proposes a 0.90 USDC report while another operation has already committed 1.00 USDC. That purchase fits both limits. A 1.40 USDC quote exceeds the per-purchase cap. A third quote fits the remaining budget, but the recipient changes before signing. The system has to make a separate decision for each request.

Enforce AI agent spending limits at three points. Reserve the token amount in the buyer application. Apply AgentKit's network and action policy before runtime execution. Check the exact payment payload at the signer. In a denial test, count calls to the signer so you know whether the request stopped before a signature could be produced.

Put the purchase limits into the approval

Consider a research agent buying freight data for a dispatch planner. The operator approves a specific seller and report edition, and lets the agent accept a price up to a stated amount. Both sides need to know what the quote covers. The merchant identifies the exact file and delivery terms. The buyer's application stores those terms and the operator's spend decision. The signer sees the transfer fields and a trusted reference to the approval.

A purchase approval should define the accepted merchant, recipient, network, token contract, payment operation, per-purchase cap, budget period and aggregate allowance. Include the expiry and identify the wallet to which the grant applies. Keep the merchant's business identity and receiving address in separate fields. One merchant can have different addresses on different networks and can rotate a receiving address during an integration. A new destination deserves the same source checks as the original.

Approval field

Illustrative value

What to compare before spending

Offer

Named edition of a freight-delay report

Merchant, offer identifier and terms revision

Network and asset

One configured EVM chain and one six-decimal token contract

Canonical chain ID and exact contract

Receiving address

One approved merchant recipient

Destination decoded from the actual operation

Authorized method

Direct token transfer

Requested signing method and transfer data

Single purchase

At most 1,200,000 token base units

Exact quoted debit against the ceiling

Task allowance

3,000,000 units including unresolved commitments

Settled debits plus reservations and proposed debit

Time and identity

One expiry and one stable key per purchase

Fresh binding among approval, wallet and intent

The amounts assume a verified six-decimal asset. Use integer base units for the ledger and retain the chain and token contract alongside them. A ticker may look familiar while describing a different asset. If you display a fiat estimate to the buyer, store the actual approval in the currency and units enforced by the system. Decide separately whether native gas belongs in the allowance. A useful policy can specify a stablecoin cap for the report and a separate cap for network fees.

The approval can specify fixed fields and permitted ranges. An operator might accept lower prices for the same report from the same merchant and require reapproval for any change in the file edition. A merchant update that shifts the receiving address changes a fixed part of the example approval. Show the buyer what changed and obtain approval for the independently verified address. The model can describe the difference. Keep the authority to update approved terms in the operator's application.

An optional ERC-8004 lookup can provide context before payment. Resolve the expected chain, registry and agent ID together. Review the attached identity or metadata for the purpose your application uses it for. If an advertised wallet or endpoint differs from the configured merchant, treat that as a reason to review the merchant relationship. The ERC-8004 proposal describes agent identity, reputation and validation. Spending authority comes from the buyer's separate approval. ERC-8004 specification

The signer should verify only the facts it can observe or receive from a trusted service. For example, the ERC-20 transfer exposes which token will be moved, in what amount and to which destination. The approved report edition lives in the application record. Link that record to a particular operation, and preserve the association if the agent later edits its working context or selects a different report.

Reserve funds before handing work to AgentKit

Use a ledger keyed by the buyer grant. It should track settled debits and reservations for attempts whose outcome remains open. After the initial 1.00 USDC commitment in the example, 2.00 USDC remains. Reserving the 0.90 report leaves 1.10. The new 1.40 request fails the per-purchase cap. Two simultaneous requests of 0.70 would each fit the per-purchase cap and each appear to fit the remaining 1.10 when evaluated against the same old balance. That is where a separate application control matters.

Check the remaining allowance and create the reservation in one atomic operation. A database transaction can serialize writers on the budget record or apply a conditional update that fails if the grant would be overdrawn. Use a unique operation key tied to the exact offer and approval. An existing key should recover the old reservation after a retry. A repeated key with a different price, recipient, asset or grant belongs in a conflict state until an operator or documented recovery flow resolves it.

Choose a ledger design that can record uncertainty at every boundary. A denied quote can log a decision without reserving funds. A reserved request that never reached a signer can release its reservation after definitive denial. When a signing or submission response disappears, keep the previous commitment until the underlying payment is reconciled or a trusted process establishes that no usable authorization remains. If a late transfer settles, deduct it from the reservation and record that settlement once. An uncertain response rarely supplies enough evidence for an automatic refund of budget capacity.

Set a recovery deadline for operators to revisit unresolved attempts. A deadline on the operational task can trigger an investigation. It does not by itself prove that a submitted transaction failed. If the agent stops because an earlier attempt tied up its allowance, it can report the existing reservation and status. That gives the operator a path to recover the budget without asking the agent to invent a second payment.

If the application supports several agents that share one budget, route every reservation through the same allocation path. A task worker and an operator's manual override can otherwise read different snapshots. Record manual modifications separately and associate them with the operator's grant. For high-concurrency buyers, wallet-local limits can provide an independent upper bound if all sign requests go through an enforcement service that understands the same units and authorization period.

There is a tradeoff between holding a reservation and keeping the agent available for the next task. A payment with incomplete confirmation can keep budget tied up. Design the application to use a bounded reconciliation queue instead of a timed release with no evidence. For a workflow that values availability over throughput, a buyer can choose a separate allowance for another authorized task. Any extra allowance needs its own approval and should remain visible in the audit record.

Use AgentKit to gate the action

AgentKit documents runtime checks for the network allowlist, the action's network support, write permissions, and whether execution requires confirmation. Supply the network context from approved application configuration. With the public PayKit product action, use the required EVM chain context for the selected payment. The buyer integration still needs to match that context to the route and the wallet. AgentKit runtime configuration

import { ExecutionRuntime, PolicyEngine } from '@goatnetwork/agentkit/core'

const runtime = new ExecutionRuntime(new PolicyEngine({
  allowedNetworks: [approved.networkContext],
  maxRiskWithoutConfirm: 'low',
  writeEnabled: true,
}))
import { ExecutionRuntime, PolicyEngine } from '@goatnetwork/agentkit/core'

const runtime = new ExecutionRuntime(new PolicyEngine({
  allowedNetworks: [approved.networkContext],
  maxRiskWithoutConfirm: 'low',
  writeEnabled: true,
}))
import { ExecutionRuntime, PolicyEngine } from '@goatnetwork/agentkit/core'

const runtime = new ExecutionRuntime(new PolicyEngine({
  allowedNetworks: [approved.networkContext],
  maxRiskWithoutConfirm: 'low',
  writeEnabled: true,
}))

The sample assumes the buyer application supplies an approved network context and controls access to this write-enabled runtime. Record the actual action to be called and the configured policy. The public PayKit product payment action in AgentKit 0.3.0 is high risk and explicitly requires confirmation. Generate that signal from a trusted buyer decision. If the model can set it on its own, the bit describes what the caller asked the SDK to do and supplies no independent authority. AgentKit 0.3.0 published package

The runtime evaluates action metadata and invocation context. Its documented policy fields cover the action admission decision. The application budget remains in the ledger, and the signer check remains at the wallet. Changing the risk threshold does not add an amount cap to the runtime. A team reviewing a payment trace should see the amount decision emitted by the application and the network and confirmation decision emitted by the runtime.

Keep runtime execution as the normal route for registered payment actions. If application code can also call a service or wallet directly, ensure those paths meet the same grant and signer control requirements. Restrict the model to the tools needed for the task, and keep wallet credentials out of the model's context. Give a read-only identity lookup its own permission. Adding a signed payment action to the same tool group can accidentally extend which processes can reach write operations.

Treat read and recovery calls deliberately after a denial. A network policy change can block a future write while an older authorized payment still needs reconciliation. Preserve a permitted way for an operator to read the relevant status or submit an authorized recovery request. Verify the behavior of each recovery action in the installed release, including whether it can replay an idempotent session creation. The operator should be able to investigate an old commitment after stopping new signing.

Check the exact operation at the signer

The signer receives the actual request, which may differ from the input the runtime admitted. The action could have received a new seller quote, selected a different token, or timed out long enough for the original approval to expire. Fetch the current reservation and compare the exact amount, network, token contract, recipient, wallet identity and operation type. Check that the approval is still current and the operation can consume the reservation only once under your policy.


Budget and recipient checks in front of a protected signing key

For a direct ERC-20 payment, the token contract receives the transaction call and the merchant recipient is a field of the transfer itself. Check both. Scope the approved operation to the supported transfer function and enforce the approved token debit. If your agent instead signs typed data or submits a wallet relayed request, use a check that understands the relevant signing method and fields. Token allowance changes, transfers and typed authorizations can create different rights. Give each one a separately reviewed policy before accepting it at the signing boundary.

A signer can look up the reservation through a trusted internal interface or validate a limited authorization issued for the pending operation. In either design, bind the request to the supported wallet, approved fields, expiry and unique attempt. Confirm that the signer can fail closed if the protection service is unavailable. Providers may expose controls on specific signing methods. Verify the exact provider policy and chain support before relying on them for the operation. Privy wallet policies

Address changes reveal where the checks take effect. A strict binding causes the example signer guard to stop even though the admitted runtime network and amount remain valid. The application can open a fresh approval request after verifying the change through the seller relationship. A buyer that expects legitimate rotation can instead authorize a tightly scoped set of destinations. Record how that set was approved and which address was chosen for each purchase. A registry record can help an operator investigate a change, while the grant remains the authority at the signer.

Do the final comparison as close as possible to the signing call. An application that builds the operation from an immutable approval can reduce data changes along the path. The signer should still verify the transaction it actually receives. If it sees a different amount, decide whether to create a replacement reservation under the original authorized range or pause for approval. Reusing the previous reservation after changing the transaction makes the ledger's audit trail diverge from the debit it intended to control.

Bind the integer reservation to an immutable payload digest after your application has normalized the approved transaction. Choose a canonical representation that includes the network, wallet, asset contract, method, recipient, amount, and expiry. A digest alone cannot tell a buyer what they approved. Keep the human-readable purchase terms and the version of the canonicalization rule with the approval record. If a requested signing operation changes after approval, the verifier will compare the final normalized fields and can capture which field changed. In a production audit, that makes it possible to distinguish a legitimate quote update from a request that no longer fits its grant.

Decide what a successful call consumes. Many sending APIs sign and submit as one operation. If the call succeeded locally and the network result is unknown, the original reservation remains associated with that reference. If the SDK or wallet exposes separate signature and broadcast steps, define which process is allowed to hold and submit a completed signature. Protect the signature wherever it can be used to move funds. Use the wallet's documented status or controlled recovery procedure to resolve the original attempt. The integrity of the budget still depends on tracking that commitment after the first boundary has admitted it.

Test the policy with a signer counter

The local fixture accompanying this guide uses the PolicyEngine module from the published AgentKit 0.3.0 archive. A small application harness implements the budget and final recipient check. The signer is a counter inside that harness. The fixture uses synthetic asset and recipient labels and never sends a wallet request or a transaction to a network.

Case

Application reservation

AgentKit policy evaluated

Fake signer calls

Observed result

0.90 USDC and approved receiver

Granted

Yes

1

The fake signer boundary was reached.

1.40 USDC and approved receiver

Denied

No

0

The application enforced the per-purchase cap.

0.60 USDC, receiver changed after runtime admission

Released after denial

Yes

0

The signer guard requested new approval.

The harness also checks that the runtime policy denies the purchase action metadata when confirmation is absent. The final commitment stays at 1.90 USDC in fixture units. It includes the original 1.00 and the accepted 0.90. The guard releases its 0.60 reservation after the fixture records that it stopped before signing. For a real deployment, get that result from instrumentation at the signing service and account for multiple attempts that might share an operation.

Record the safe intent identifier, the approval and reservation, the runtime admission decision and the actual signing disposition. A successful policy test identifies which rule took effect and whether the signer was asked. Keep raw signing payloads or recovery secrets in appropriate restricted storage. A zero count should be meaningful. A telemetry gap needs a different status so an operator can tell whether instrumentation worked.

Test application storage under concurrent requests before launch. Send two approved quotes whose combined amount exceeds the remaining allowance. Verify that their reservations cannot both commit and that the budget seen by multiple workers stays consistent. Exercise the lost-response path separately by letting the original payment appear unresolved after a signing call. The reservation should stay in place until the operation is reconciled. These cases exercise database and downstream behavior outside the three-case local harness.

For the release checklist, use the real signer audit event or a controlled test provider from the environment the agent will use. Capture one permitted purchase, a rejected amount, and a changed recipient. Keep the inputs stable except for the field under test. A developer should be able to follow the acceptance record from the approved task to the actual signing disposition, including whether the same operation was retained across a retry. That makes it possible to change the spending policy later and check that its enforcement still happens at the expected point.

FAQ

Does AgentKit provide a cumulative spending ledger?

The documented policy engine gates action execution by network, write permissions and confirmation. The example uses a separate application ledger for cumulative spending and reservations.

When can a payment reservation be released?

A definitive rejection before signing can release it when no other attempt can consume it. If a transfer or usable authorization may exist, keep the amount committed until the original attempt is resolved.

Can an agent accept a changed receiving address by itself?

The buyer can explicitly approve a rule covering changes, with its own verification and revocation controls. In the example, the authorization binds one destination, so a new address requires an independently verified and approved update.

[01]

AI Knowledge base

More Articles

More Articles

More Articles