Crash on step 5? The run resumes at step 5. Reliability comes with the SDK: steps are checkpointed, failed calls retry, and a run can wait for people. In Python, TypeScript, or Go.
from agnt5 import function, workflow, FunctionContext, WorkflowContext
@function(retries=3, backoff="exponential")
async def issue_refund(ctx: FunctionContext, order_id: str) -> str:
... # flaky payment API: retried on failure
@workflow
async def refund_order(ctx: WorkflowContext, order_id: str) -> dict:
order = await ctx.step(fetch_order, order_id) # checkpointed
decision = await ctx.wait_for_user( # can wait hours or days
question=f"Refund {order['total']}?",
input_type="approval",
options=[{"id": "approve", "label": "Approve"},
{"id": "reject", "label": "Reject"}],
)
if decision == "reject":
return {"status": "declined"}
await ctx.step(issue_refund, order_id) # never runs twice
return {"status": "refunded"}import { fn, workflow } from '@agnt5/sdk';
import type { Context } from '@agnt5/sdk';
const issueRefund = fn('issue_refund')
.retry({ maxAttempts: 3 })
.backoff({ type: 'exponential' })
.run(async (ctx: Context, input: { orderId: string }) => {
// flaky payment API: retried on failure
});
export const refundOrder = workflow('refund_order',
async (ctx: Context, input: { orderId: string }) => {
const order = await fetchOrder(ctx, input); // checkpointed
const decision = await ctx.waitForUser(`Refund ${order.total}?`, {
inputType: 'approval', // can wait hours or days
options: [{ id: 'approve', label: 'Approve' },
{ id: 'reject', label: 'Reject' }],
});
if (decision === 'reject') return { status: 'declined' };
await issueRefund(ctx, input); // never runs twice
return { status: 'refunded' };
});agnt5.RegisterFunction(worker, "issue_refund", issueRefund,
agnt5.WithRetry(3, 250, 5000), // flaky payment API: retried
agnt5.WithBackoff("exponential", 2),
)
agnt5.RegisterWorkflow(worker, "refund_order",
func(ctx *agnt5.Context, in RefundInput) (string, error) {
order, err := agnt5.Step(ctx, "fetch_order", func(context.Context) (Order, error) {
return fetchOrder(ctx, in.OrderID) // checkpointed
})
if err != nil {
return "", err
}
decision, err := ctx.AskUser(agnt5.UserInputRequest{ // can wait hours or days
Prompt: "Refund " + order.Total + "?",
Type: agnt5.HITLApproval,
Options: []agnt5.HITLOption{
{Label: "Approve", Value: "approve"},
{Label: "Reject", Value: "reject"},
},
})
if err != nil {
return "", err // propagate: the run suspends here
}
if decision == "reject" {
return "declined", nil
}
return agnt5.Step(ctx, "issue_refund", func(context.Context) (string, error) {
return issueRefund(ctx, in.OrderID) // never runs twice
})
})Flaky tools, APIs, and models.
Failed calls retry with backoff. Steps that already succeeded don’t run again.
Waiting on people.
A run can pause for an approval for hours or days, then carry on from that step.