Anlyon vs building it yourself

Build it yourself when one agent runs in one process, the developer is the approver, and the provider already offers idempotency and a lookup. Use Anlyon when several agents share one allowance, someone other than the requester approves, or the agent must not hold the provider key. The work is in the failure windows: two agents reserving the same last $100, a retry that refunds twice, a timeout nobody can classify.

A few lines on your server, then connect a user.

Last checked

2026-11-13. Each statement about another product was read on that product's own site or docs, and carries its date and source where it is made. One that could not be confirmed that day keeps its earlier date.

The approve button takes an afternoon. The work is in the failure windows behind it. Anlyon has built them: an atomic reservation, an approval bound to the exact request, a vault with no read endpoint, and a receipt for every outcome.

The short answer

When to build it yourself, and when to use Anlyon

Build it yourself when one agent runs in one process, the person approving is the developer at the keyboard, and the provider you call already offers idempotency and a way to look up what happened. A framework approval switch and a database row are enough there.

Use Anlyon when several agents, sessions or keys must draw from one allowance, when someone other than the requester approves, when the agent must not hold the provider key, or when you need a record of what the provider did, not what your code believed.

Either way, the sections below are the specification. Use them as a checklist even if you never use Anlyon.

Failure windows. Five jobs, and where each one breaks

Each job in the order it bites: what the first version looks like, what breaks it, what has to hold, and what Anlyon does.

01 / 05

How hard is a shared limit across agents?

The first version

Read how much is left, compare it with the amount, call the provider, then add the amount to a counter.

Where it breaks

  • Check, then act

    Two agents read $100 left at the same moment. Both see room for an $80 refund and both dispatch. The counter ends at $160 against a $100 limit, and every single-agent test passed.

  • An allowance per session

    A limit held in the agent's memory, or a counter keyed to one API key, starts again with every new session or key. Adding an agent adds an allowance.

  • Releasing on a timeout

    The call times out, so the code releases the reservation. The refund did land. It no longer counts, and the next one goes through.

What has to hold

An atomic reservation before dispatch, in one store every agent shares, settled from the outcome and still held while the outcome is unknown.

With Anlyon

Every agent, session and key draws from the same limit, reserved before dispatch, and a new session or key does not get a new allowance. Scope a limit to users and each of your users gets their own counter. A limit counts money or a unit you declare, such as emails, and an unknown outcome keeps its allowance held.

limit.ts
// The version that passes every single-agent test.const { remaining } = await db.one('select remaining from limits where id = $1', [limitId]);if (amount > remaining) throw new Error('over the limit');await stripe.refunds.create({ payment_intent: pi, amount }); // two agents both get hereawait db.none('update limits set remaining = remaining - $1 where id = $2', [amount, limitId]);// The shape that holds: reserve atomically before dispatch, settle after.const claim = await db.oneOrNone(  'update limits set reserved = reserved + $1 where id = $2 and consumed + reserved + $1 <= amount returning id',  [amount, limitId],);if (!claim) throw new Error('refused before dispatch');// Dispatch. On success, move the amount from reserved to consumed.// On a lost response, keep it reserved until you know what happened.

02 / 05

What does it take to bind an approval to the exact request?

The first version

Store a pending row, show the reviewer what the model wrote, flip a boolean, then run the tool.

Where it breaks

  • The reviewer approves a summary

    The model writes "Refund $12.50 for order 4411". The arguments say 125000 cents. The approver reads the sentence, not the request.

  • The request changes after review

    The agent retries with different arguments under the same approval id, or someone edits the tool definition while the approval waits.

  • The requester approves itself

    The agent's key can call your approve endpoint, because one service account does both.

  • The callback arrives twice

    A double-clicked button or a retried webhook marks the approval twice, and each one dispatches.

What has to hold

Persist the canonical request, show the reviewer that request, recompute a digest at dispatch and refuse on any difference, keep the permission to decide apart from the permission to ask, and make approve-then-dispatch happen once.

With Anlyon

The approval is bound to a SHA-256 digest of the request, target, versions, preconditions and expiry. Anlyon recomputes it before dispatch and refuses on any difference. A changed request sent with a reviewed preview is refused with PREVIEW_MISMATCH. The credential that requested an approval can never be the one that decides it. On a call for one of your users, that user decides it in your app.

03 / 05

Where should the provider's API key live?

The first version

Put the Stripe key in an environment variable the agent's process reads, and trust the tool code to call only what it should.

Where it breaks

  • The process holds the key

    Whatever the agent's process can read, a prompt injection or a buggy tool can reach. A gate inside that process is skipped by any code path that calls the provider directly.

  • An input picks the host

    The URL is built from model input, so the key meant for one API is sent to another.

  • Rotation is per deployment

    Every service that copied the key has to be found and redeployed when it changes.

What has to hold

A separate service that holds the key, accepts named operations with validated input, binds each secret to its destination host, and never returns the value.

With Anlyon

An action references {{secret:NAME}} and Anlyon resolves it at dispatch. The secret is bound to a destination and checked again at dispatch. An action that carries a secret has a fixed host, so an input cannot choose where the credential is sent. The vault is write-only: no API returns a secret's value. On a call for one of your users, the header names that user's own connection instead, and Anlyon fills it at dispatch.

04 / 05

What should happen when the provider never answers?

The first version

Wrap the call in a try block, retry on a timeout with backoff, and log success or failure.

Where it breaks

  • A timeout is not a failure

    The request may have landed. Retrying a refund on a timeout is how one refund becomes two.

  • Your idempotency layer races

    Reading a cached result and then running the handler lets two concurrent requests with the same key both run. We shipped that bug ourselves, and the write-up is linked below.

  • Keys expire

    Stripe's API reference says API v1 idempotency keys can be removed once they are at least 24 hours old, and a key reused after that makes a new request. A retry the next morning is a second refund.

    Checked 2026-11-13 · Stripe idempotent requests

  • Some APIs have neither idempotency nor a lookup

    Then "did it happen?" needs a read-back you design for each provider, and an operator to decide when the read-back finds nothing.

What has to hold

An operation identity saved before dispatch, a third state beside success and failure, a reconciler that reads the provider's own record and never writes, and an operator path for what it cannot settle.

With Anlyon

When a provider's response is lost, Anlyon records the outcome as unknown, never failed, does not send the request again, and settles it from the provider's own record. Not finding the operation proves nothing: it stays unknown, with its allowance held, until a replay or an operator resolves it.

05 / 05

What does the audit record need to say?

The first version

Log the tool name, the arguments and whether the call returned 200.

Where it breaks

  • Logs record what your code believed

    They do not say who approved which exact request under which policy version, or what the provider's own record said afterwards. When a customer asks whether the refund happened and who allowed it, you join three systems by timestamp.

  • Later evidence overwrites earlier evidence

    A status column updated in place loses the timeout that came before the success, which is the part an incident review needs.

What has to hold

One record per operation: the reviewed request, the decider, the policy version, each dispatch, the provider's evidence, and an append-only trail of what was learned later.

With Anlyon

Every decision records the decider, the timestamp, the note and the governing policy version. Every action returns a receipt with a grade. Confirmed means a read-back matched. Acknowledged means the provider accepted the request and nothing read it back. Unknown means no usable response, and Anlyon does not send it again. It stays unknown until a read-back or an operator settles it. Failed, refused and denied mean it did not run. Evidence on an effect is append-only, and every invocation, approval and receipt carries the id of the user it acted for.

Side by side

The same five jobs, side by side

What you build and run, what Anlyon does instead, and what stays your job either way.

Building agent limits, approvals, credential custody and receipts yourself, compared with Anlyon
JobBuilt yourselfWith AnlyonStill yours with Anlyon

Shared limit

A ledger with an atomic reservation, settlement on each outcome, and a hold for unknown outcomes.

A limit per user or per environment, in money or a declared unit, reserved before dispatch.

Choosing the amounts. Routing every write through Anlyon, because a direct call is not bounded.

Exact approval

A stored canonical request, a digest checked at dispatch, decide permissions, and one dispatch per approval.

A SHA-256 digest of the request, target, versions, preconditions and expiry, recomputed before dispatch.

Choosing who decides: the user in your app, or an approver on your team.

Credential custody

A service that holds keys, fixes hosts, and serves named operations only.

A write-only vault, or each user's own connection. Resolved at dispatch and bound to their host.

Removing other copies of the key from the agent's environment.

Lost responses

Operation keys, a third state, a reconciler for each provider, and an operator queue.

Recorded unknown, never sent again, settled from the provider's own record where a lookup exists.

Resolving what a read-back cannot settle, with evidence.

Audit record

A record per operation joining the request, decision, dispatch and provider evidence.

A graded receipt with append-only evidence, and decisions with their policy version.

Copying it into your own store for as long as you must keep it. Traces export as OTLP JSON for each run.

In your code. The same refund, through Anlyon

The key goes into the vault once. The agent holds an Anlyon key that can only invoke. The limit, the approval and the receipt sit on the action, so a second agent or a new session meets the same ones.

refund.ts
import { Client } from '@anlyonhq/sdk';// Once, from a deploy script, with an operator key.const ops = new Client({ apiKey: process.env.ANLYON_OPERATOR_KEY! });await ops.secrets.put('STRIPE_KEY', {  value: process.env.STRIPE_KEY!,  allowedHosts: ['api.stripe.com'],});await ops.actions.create({  name: 'refund',  requiresApproval: true,  adapter: {    type: 'stripe.refund',    config: { account: 'acct_1Nxyz', mode: 'live', currency: 'usd' }, // the key must match the mode    credentialSecret: 'STRIPE_KEY',  },});// One allowance for every agent, session and key in this environment.await ops.impactLimits.create({  name: 'Refunds per day', dimension: 'money', currency: 'usd', period: 'day', amount: 50_000,});// In the agent, with a key that can only invoke.const agent = new Client({ apiKey: process.env.ANLYON_AGENT_KEY! });const { data } = await agent.actions.invoke(  'refund',  { paymentIntent: 'pi_3Pabc', amount: 1250, currency: 'usd' },  { operationKey: 'order-4411-refund' },);// pending_approval until an approver decides this exact request.console.log(data!.status, data!.effectId);

Together

You can do both

Route the calls that move money or reach a customer through Anlyon actions, and keep the rest in your own code. Anlyon governs every action routed through it, so start with the writes you would least like to explain.

For a call you cannot move yet, the SDK wrapper approvals.gate() waits for an approval decision before calling your function. Your process keeps running the function with your credential, and you get the decision and the record.

Building it yourself, answered. The questions teams ask before they build their own.

Anything still unanswered is worth an email.

support@anlyon.com

Email us

Build it when one agent runs in one process and the reviewer is the developer: a framework approval switch and a database row are enough. Once several agents share an allowance, someone other than the requester approves, or the agent must not hold the key, you are building a ledger, a request digest, a vault and a reconciler. That is what Anlyon runs for the actions routed through it.

Two parts. The reservation has to be atomic and shared, or two agents spend the same last $100. And a timeout has to keep its reservation held as unknown, because the request may have landed. Releasing it on a timeout lets the next call through on top of one that already happened.

Because the first request may have reached the provider. Retrying a refund on a timeout is how one refund becomes two. Anlyon records a lost response as unknown, does not send the request again, and settles it from the provider's own record. What the lookup cannot find stays unknown until a replay or an operator resolves it.

Yes. Anlyon governs the actions routed through its hosted executor. A tool your own code calls directly is not routed through Anlyon and is not governed by it, so put the calls that move money or reach customers behind actions first.

Let your agent act for your users, safely.

A few lines of server code, then send a user a connect link. Nothing to host.

$ claude mcp add --transport http anlyon https://api.anlyon.com/mcp