DEV Community

Cover image for The refund button is the easy part
Dhrubojyoti Gangopadhyay
Dhrubojyoti Gangopadhyay

Posted on

The refund button is the easy part

Two support cases ask for a ₹2,400 refund. In one, there is no refund on record. In the other, a colleague has already issued it. The messages can be identical. The right next action depends on current payment state.

What AWS announced

On December 1, AWS announced Greenlight in preview. Greenlight helps draft and analyze policies, including checks for whether sequences of tool calls can violate a rule. After approval and deployment, the gateway policy engine or Strands Box enforces the policy. Coverage depends on which execution paths the policy engine actually sees. AWS announcement · Greenlight user guide

Make the approval specific

In an illustrative refund flow, I’d fetch the order and refund status from the system that owns the records. I’d show the reviewer the order ID, amount, existing refunds and supporting evidence. I’d tie approval to that exact action and reconcile the latest state when it’s time to execute.

If the record changed while approval was pending, the test should require renewed review. The system handling payment still needs a way to prevent a concurrent duplicate, such as a provider-supported idempotency key for the same operation and an atomic eligibility check where the refund is recorded. A timeout leaves the outcome uncertain until it can be reconciled.

Two cases to put in a regression test

The amounts and IDs in this fixture are illustrative:

[
  {
    "order_id": "DEMO-042",
    "requested_paise": 240000,
    "existing_refund_paise": 0,
    "expected_next_state": "awaiting_human_review"
  },
  {
    "order_id": "DEMO-042",
    "requested_paise": 240000,
    "existing_refund_paise": 240000,
    "expected_next_state": "already_refunded",
    "expected_new_refund_attempts": 0
  }
]
Enter fullscreen mode Exit fullscreen mode

Then I’d add a third run: start with a clean record, pause for approval, and have another authorized operator complete the refund in the test fixture before the agent resumes. Verify the number of outbound refund attempts and the resulting refund record independently of the agent’s final message.

Where Sahkarmi fits

Sahkarmi is the open-source desktop AI coworker I’m building. It can do the preparatory work across apps and pause for your approval before payments, messages and posts. The refund fixture above is a proposed design test. A verified refund workflow needs checks in the payment system and a clear path for resolving uncertain results. Sahkarmi

Applied AI, Day 47. What’s the one fact your agent must check again just before it acts?

Top comments (0)