Developer series, part 1
Check your agent's first real action
VeriProof works with agents built a lot of ways: six language SDKs, framework adapters, Copilot Studio, computer use and a gateway. Underneath all of them is one small loop. Learn it once and the rest of this series is the same idea in a different setting.
The agent we'll build on
We'll use a refund support agent from a demo we run at meetups. It chats with customers and can issue refunds, and the business has one rule: anything over $500 needs a manager.
Two customers show up. Maya wants $120 back on a small order. That's under the limit, so the refund goes straight through. Daniel wants $900. That goes to a manager in Teams, who notices the order is past the 30-day return window and approves $600 instead. The agent refunds $600 and tells Daniel why.
The chat replies in the demo are scripted so they don't wander on stage. The policy decision, the manager's review and the record behind it are real. The code below is TypeScript, and the same calls exist in the Python, .NET, Java, Go and Rust SDKs.
Wrap the part that changes something
Your agent probably does a lot of things. Most of them, like looking up an order or drafting a reply, don't need a check. The refund does, because it moves money. So that's the one call you wrap.
import { Veriproof } from '@veriproof/sdk-core';
const veriproof = Veriproof.fromEnv();
const result = await veriproof.govern(
'support.issue_refund',
{ ticketId, orderId: order.id, amount: order.total, currency: 'USD' },
({ input, invocationId }) =>
billing.refund({ ...input, idempotencyKey: invocationId }),
{
facts: {
refund_amount: order.total,
days_since_delivery: order.deliveredDaysAgo,
},
review: {
profile: 'support_refund_approval',
proposedActionSummary: `Refund $${order.total} for order ${order.id}`,
},
},
);Here's what each argument does.
'support.issue_refund'is the action's name. It says what kind of action this is, and rules and reports group by it.{ ticketId, orderId: order.id, amount: order.total, currency: 'USD' }is the input: the refund itself, exactly what your function receives. It stays in your application. Reviewers and the record get the facts below, and the input is recorded only if you turn on content capture.({ input, invocationId }) => billing.refund(...)is the function that actually issues the refund. VeriProof calls it only after the check says it can run, so a stopped refund never reaches your billing system.factsholds the values a rule compares against, hererefund_amountanddays_since_delivery. A governance engineer writes the $500 limit againstrefund_amount, and VeriProof shows them which facts your agent sends. (If you're curious what those rules look like, Meet Rego walks through one.)reviewsays what happens if a rule wants a person.profile: 'support_refund_approval'names the review workflow the refund goes to, andproposedActionSummaryis the line the manager reads first. Leavereviewout and a rule that needs a person stops the refund withreview_context_requiredinstead of opening a review.
One more detail worth copying: the refund uses invocationId as its idempotency key. If anything retries, your billing system sees the same key and won't refund twice.
Handle what comes back
govern() always hands back a result with a status. You don't need a branch for every one of them on day one, but you do need to treat them differently.
switch (result.status) {
case 'completed':
case 'completed_with_warning':
case 'transformed':
return reply(`All done. I've refunded $${result.value.amount}.`);
case 'review_required':
await reviews.save(result.review);
return reply("That's over my limit, so I've asked a manager.");
case 'blocked':
return reply(`I can't issue that refund. ${result.message}`);
default:
return reply("I couldn't check this refund right now, so I haven't issued it.");
}The first three statuses all mean the refund ran. completed_with_warning means a rule flagged it for someone to look at later, and transformed means a rule changed the input before it ran, like capping an amount. In both cases you get result.value back.
blocked means a rule said no, and result.message says why in plain words, so you can pass it along. Everything else, like a timeout or VeriProof being unreachable, lands in default. Your function didn't get the go-ahead, so the agent says so and doesn't refund. If you need to know whether work might have started before something went wrong, result.execution tells you.
When the manager says yes, but less
Daniel's refund is where it gets interesting. It came back review_required, so the agent saved the review checkpoint and told Daniel a manager is looking at it. The manager looks at the order and its delivery date in Teams, and approves $600.
VeriProof sends your app a signed callback with that decision. Your app passes it to the review runtime, which verifies it, and then you resume the work:
const resumed = await reviews.resume(checkpoint, ({ input, reviewResponse, invocationId }) =>
billing.refund({
...input,
amount: approvedAmount(reviewResponse, input.amount),
idempotencyKey: invocationId,
}),
);It's the same refund function as before, with one change: the amount comes from what the manager approved, not what Daniel asked for. Before your function runs again, VeriProof rechecks the current facts and policy, so an approval can't be used for something that's changed since.
Because the checkpoint is saved, this works even if the manager takes an hour and your service restarted in between. The demo keeps checkpoints in a file for exactly that reason.
What you get for free
Once that loop is in place, a lot happens without more code from you. Every refund, allowed or not, is recorded with the rule version that decided it, and the reviewed ones show who approved them and for how much. Your governance engineer can change the $500 limit and try it in Shadow without you shipping anything. And when someone asks why Daniel got $600, the answer is one link away instead of a dig through logs.
Where to go next
The quickstart gets your first check running in your language in a few minutes. If you'd like to see the people on the other end first, the simulators let you follow a decision into each role's portal without writing any code.
The rest of this series picks up where this one stops:
- Part 2, When a person steps in: reviews that take all afternoon, rejections, expiries and restarts.
- Part 3, Facts your rules can use: what to send so your governance engineer can write good rules.
- Part 4, The check inside your framework: the same check through a framework adapter.
- Part 5, When you can't change the code: Copilot Studio, computer use, MCP and the Agent Gateway.
- Part 6, Testing code with a check in it: unit tests, offline review rehearsals and Shadow.
Get your first check running
Start with the quickstart for your language, or test this workflow with the free 60-day Developer evaluation.