Blog
Engineering

Your agent retried. Your customer should not have to approve twice.

Keep one customer approval attached to one agent action through retries and restarts. A runnable Pushary Partner example, with explicit limits and failure cases.

Aadil Ghani
Aadil Ghani
Founder, Pushary
Oct 15, 2026Updated Oct 23, 20265 min read
Share
A saved operation reads its existing decision: pending waits, explicit approval proceeds to validation, and denied or expired decisions stop.

Resume from the saved decision ID. Pending means wait; denial, expiry or cancellation means do not execute. An explicit approval still needs action validation, an atomic execution claim and downstream idempotency.

View full-size image

One operation should keep one approval request, even when the agent job retries. With Pushary Partner APIs, that means a stable idempotencyKey for creation, a saved decisionId for recovery, and an explicit approval check before the action runs.

A retry is normal. Asking the customer again because your worker restarted should not be.

This was one of the problems behind building our Partner APIs. Sending the question is only the start. The product needs to remember what it asked, who it asked, and what happened next.

Give the operation an identity before asking

Consider a support agent proposing a EUR 4.80 refund. This is a synthetic example, not a customer incident.

Your application creates an operation record before calling Pushary. It stores the recipient, order, amount, currency and action version. That record stays stable across worker attempts. The approval key comes from that operation, not a random value generated every time the job runs.

Change the action or recipient and you need a new approval. A second refund is a second operation, even if its amount and question happen to match the first.

Pushary scopes the creation key to the site and recipient, with a 24-hour deduplication window. Within that window, a repeated create reuses the decision, including an answer it already received. After that window, resume using the saved decision ID. Do not treat the creation key as permanent storage.

Run the example without executing a refund

Download retry-approval.mjs. It uses @pushary/server, creates a confirmation question and prints its state. It never calls a payment provider.

Use a server-side Partner key and a recipient enrolled with your application. For a simulator instead of a person, follow the sandbox setup and its limits. Keep the key in your server environment.

npm install @pushary/server@2.5.0
node retry-approval.mjs operation-demo-4471 customer-demo

Set PUSHARY_API_KEY in the environment before running the script. The first call returns a decision ID. Save it with the immutable operation record. Running the same command again within the creation window uses the same key.

After a restart, pass the saved ID:

node retry-approval.mjs operation-demo-4471 customer-demo YOUR_SAVED_DECISION_ID

That path reads the existing decision. It does not create another question. The script checks that the returned decision belongs to the saved recipient and requires a confirmation answer before reporting approved: true.

Illustrative output while waiting:

{
  "operationId": "operation-demo-4471",
  "externalId": "customer-demo",
  "decisionId": "example-decision-id",
  "status": "pending",
  "approved": false,
  "actionExecuted": false
}

Even after approval, this example reports actionExecuted: false. It is a decision walkthrough, not a refund implementation.

A wait ending is not a decision expiring

decisions.ask() is convenient when the person may answer quickly. Its default caller timeout is 55 seconds. That timeout does not turn a pending question into a rejection, an approval or an expired decision.

Save the returned decision ID and check it later. Decision expiry is a separate setting. The default is one hour, with supported values from 60 seconds to 24 hours. Pending, expired, cancelled and denied decisions must not run the protected action.

If you receive an idempotency-storage error, stop and retry according to the response, including Retry-After when present. Generating a fresh key to get around that failure defeats the protection against duplicate questions.

One approval does not mean one execution

Two workers can read the same approved decision. Both can then try to refund the order.

Pushary's decision deduplication does not make your payment provider, email service or database transaction run exactly once. Before executing, your application must check that the action still matches the saved proposal and claim the operation atomically. Use the downstream provider's idempotency mechanism too. Record the result so another worker can recover without guessing whether the action happened.

A changed amount, target or recipient needs a new proposal and decision. An old yes does not authorize new work.

If the action commits but the worker loses the response, recovery also needs evidence from the backend. The agent lost the response. Did the action happen? compares two runnable examples at that boundary.

Treat callbacks as another delivery path

The downloadable example polls. For callbacks, verify the signature against the raw request body, validate the payload, and match its decision ID to your saved operation. Handle duplicate callbacks without repeating the action. Keep polling available as a recovery path.

The webhook receiver walkthrough and tests add signature verification and a durable inbox before queuing a decision recheck. They cover forged requests, concurrent duplicate delivery and storage failures without executing the protected action.

The Partner integration guide contains the callback contract and signing details. A callback alone is not permission to execute an unrelated or changed operation.

Reproduce the failure cases locally

Download the example and its test suite into the same directory. Use Node.js 20 or later and install the pinned SDK:

npm install @pushary/server@2.5.0
node --test retry-approval.test.mjs

No Partner account or API key is needed for this test. The suite starts a local HTTP server on an available loopback port, supplies a synthetic key, and launches the actual example in a fresh Node process for each attempt. It closes its server when finished. It does not call Pushary, send a phone notification or execute a refund.

Results and what they establish

Checked October 15, 2026 with @pushary/server 2.5.0. All ten scenarios passed in the local fixture run.

ScenarioObserved resultBoundary tested
Create the same operation twiceBoth processes report the same decision IDThe example sends a stable key; the fixture models deduplication
Pending decision carrying a yes valueapproved: falsePending cannot authorize work
Expired decision carrying a yes valueapproved: falseExpiry cannot authorize work
Cancelled decision carrying a yes valueapproved: falseCancellation cannot authorize work
Explicit noapproved: falseRejection cannot authorize work
Pending, then a later confirmation yesA fresh process reads approved: true; no additional createRecovery reads the saved decision
Free-text answer containing yesapproved: falseText is not a confirmation
Another recipient's decisionProcess failsRecipient mismatch stops the example
Response contains a different decision IDProcess failsDecision mismatch stops the example
Saved decision cannot be foundProcess fails; no replacement createRead failure cannot silently start a new approval

The fixture sets decision states directly. It does not simulate an hour passing, enforce the production 24-hour window, verify callbacks or prove production server deduplication. A later answer here means a state change between two process runs, not a measured delivery delay. This is a correctness walkthrough, not a latency benchmark.

Separately, Pushary's create-route tests exercise the real request handler and idempotency resolver with test storage and delivery boundaries. They cover concurrent retries, failed persistence, recipient isolation and unavailable idempotency storage. Those checks support the server code paths; they do not establish live phone delivery or exactly-once execution by a payment provider.

Questions to settle before connecting a real action

Can I retry creation forever with the same key?

No. The creation deduplication window is 24 hours. Save the decision ID and recover by reading that decision. If it is unavailable, stop and reconcile the operation instead of silently creating a new question.

Can I change the action after someone approves?

A changed amount, target or recipient needs a new proposal and approval. Store the operation and decision together. This example checks the recipient and decision ID; your application must also verify the immutable action record before execution.

Does approval guarantee the action runs once?

No. Two workers can read one yes. Your application still needs an atomic execution claim, downstream idempotency and a durable result. The example deliberately never executes a refund.

Keep the decision attached to the operation, and keep execution attached to the decision. Start with the Partner integration guide, then test the unanswered and retry cases before connecting a real action.

Read our editorial and corrections policy for how we distinguish product claims, synthetic examples and measured results.

Aadil Ghani
Aadil Ghani
Founder, Pushary

Building Pushary so an AI agent can reach you on your phone and wait for a yes before it does something you would not want.

Read next

Engineering

Verify approval webhooks before your agent resumes

A callback should wake your worker, not authorize an action. Verify its signature, save it once, then check the decision against your saved operation.

Oct 19, 2026Updated Oct 23, 20263 min readAadil Ghani
Engineering

Your customer should know exactly what they are approving.

An approval button is the last step. First, name the person, show the action and make sure the answer stays attached to the work.

Oct 15, 2026Updated Nov 4, 20265 min readAadil Ghani
Product

I got tired of rebuilding human approvals. So we built Partner APIs.

A new agent should not mean another approval system. Here is the problem behind Pushary Partner APIs, and the decisions we made while building them.

Oct 15, 20264 min readAadil Ghani

Let your agents work. Stay in control.

Get the questions that need you on your phone or Mac. Approve, reject, or answer so your agent knows what to do next.