Agent Harness Tutorial · End to end · Zoom level 2
The payout flow
The real flow, from a test on Azure: Rohan asks to release ₹25,001 on claim CLM-010004. The automatic limit is ₹25,000, so a person must approve it.
₹25,000 or less is approved automatically by the rule policy:automatic-limit and paid in the same turn. Only bigger payouts wait.
Nothing is paid until the decision is written down. Every state change upserts the approvals row first. The claims system then checks that row itself before paying: approved, not expired, same arguments, and decided by someone other than the customer.
If the claim changed while waiting, the workflow marks the approval STALE and starts a fresh one, so Asha never approves something she didn't see.
An approval is valid for 24 hours. Asha's desk refreshes every 5 seconds.
Code view: input, process, output, the call stack, the classes
How it is done: the real code
Cut from the live repositories each time the site is built, so it always matches what runs.
claims_fnol/approvals/payout.py:116request_payout: start the approval, or pay within the limit async def handle(arguments: dict[str, object]) -> ToolResult:
claim_id = arguments.get("id")
if not isinstance(claim_id, str) or not claim_id:
return _error(REQUEST_PAYOUT, "a claim reference is required")
approval = await approvals.request(
action=PAYOUT_ACTION,
args={"claim_id": claim_id},
identity=identity,
idempotency_key=idempotency_key,
conversation_id=conversation_id,
)
if approval.state is ApprovalState.WAITING:
raise PayoutRequested(approval)
if approval.state is ApprovalState.DONE:
# Named by its row, as every claims-system answer is: this answer is
# the latest word on the claim's status (AOAS `consistency`, F-21).
done = {
"id": claim_id,
"status": "paid",
"approval_id": approval.id,
"claim_id": claim_id,
"amount": str(approval.args.get("amount", "")),
}
return ToolResult(name=PAYOUT_ACTION, text=approval.result or "", structured=done)
if approval.declined:
raise ActionDeclined(DECLINED_REPLY.format(claim_id=claim_id), approval.result or "")
return _error(REQUEST_PAYOUT, approval.result or f"the payout is {approval.state.value}")