Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › AI agents

AI Agent Job Ran Twice After Restart: Find the Retry and Stop Duplicate Effects

By Freedom251 Team · · 7 min read

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A clean process restart does not mean a job ran only once. A queue, caller, function service, or workflow engine may retry or replay work when it cannot confirm that an earlier attempt finished. The key is to distinguish repeated execution from a repeated external effect, trace the same logical job across every layer, and make side effects safe to retry with a stable idempotency key.

What “the job ran twice” can mean

Start by separating the logical job from its attempts and effects. A job is the intended unit of work; an attempt is one execution of it; an effect is an action such as charging an account, sending a message, or creating a record. Two attempts do not necessarily mean two effects: the second attempt may find and return the first attempt’s stored result. Conversely, a single attempt can leave an uncertain outcome if an external service completes an action but the worker fails before recording that completion.

As an Amazon Associate I earn from qualifying purchases.

Retries and replays are normal recovery mechanisms, not proof that a process restart failed. AWS’s durable-execution guidance puts the risk plainly: “Replay and retry can each run the same operation more than once.” That is why retryable work needs duplicate-tolerant side effects, not just a reliable restart mechanism. AWS Durable Execution SDK: Idempotency and retries

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Where the second attempt can come from

A queue delivered the message again

Queue-backed consumers should be designed to tolerate duplicate deliveries. For SQS messages processed by Lambda, AWS identifies several causes of another processing attempt: the function errors or times out, acknowledgement or deletion does not complete before the visibility timeout expires, or the queue returns a transient duplicate. Check the message ID and receive count. If the same content arrives with different message IDs, investigate whether the producer sent the work more than once. AWS re:Post: Prevent Lambda function retries for the same SQS message

#1 Best Overall
Express Schedule Free Employee Scheduling Software [PC/Mac Download]
  • Simple shift planning via an easy drag & drop interface
  • Add time-off, sick leave, break entries and holidays
  • Email schedules directly to your employees

For the SQS/Lambda configuration covered in that AWS guidance, the visibility timeout should be at least six times the function timeout plus the batch-window timeout. This is integration-specific guidance, not a universal queue formula; verify the current settings and recommendations for the queue and consumer you actually run.

An asynchronous function invocation was retried

Lambda’s asynchronous invocation documentation says function errors are retried by default. It also notes that an event can be delivered more than once even when the function did not return an error, because the queue is eventually consistent. Treat retry counts and timing as service behavior to verify for your deployment rather than assuming every repeated event has the same cause. AWS Lambda: How Lambda handles errors and retries with asynchronous invocation

A caller started a new execution

If each request creates a fresh workflow execution with a newly generated identifier, the service may see two distinct starts rather than one retried start. AWS Durable Functions supports using an execution name as an idempotency key for starts: a retry must reuse the name, and the feature has payload and state constraints. AWS Lambda: Idempotency

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Teacher Record Book
  • Keep track of everything from attendance to test scores
  • Spiral bound
  • Measures 8-1/2" x 11"

A workflow replayed a step with an uncertain result

A worker can call an external tool successfully, then stop before the workflow durably records that step’s completion. After recovery, the orchestration layer may not be able to infer whether the external effect happened, so it can run the step again. Durable history and checkpoints help a workflow resume, but they do not make a separate external service’s action exactly once.

Retry labels also have different meanings in different workflow systems. Temporal distinguishes a Workflow Task failure, which the service automatically retries, from a Workflow Execution failure, which does not automatically retry unless a retry policy is configured. Identify which kind of failure you are seeing before changing a retry policy. Temporal: Tasks

Trace the duplicate from ingress to effect

Use one stable logical job ID from the moment work enters the system. Record it alongside the attempt number and the identifiers each layer assigns. This lets you tell a repeated producer submission from a redelivery, a new workflow start, or a repeated tool call.

Rank #3
Adams Job Work Order Book, 3-Part Carbonless, White/Canary/White, 5-9/16 x 8-7/16 Inches, 33 Sets (T5868)
  • QUALITY FORMS: Adams Repair Order books provide space for costs in materials and labor
  • BACK PRINTING: Forms include space on the back to record materials used in the repair
  • 33 THREE-PART CARBONLESS FORMS: Give customers one copy; retain the additional two copies for your records
  • WRAP-AROUND COVER: Fold the back cover between sets to keep forms neat and legible
  • ROOM FOR CUSTOMIZATION: A blank space at top leaves room for your company stamp; a big savings over custom-printed forms
  1. Instrument ingress and publication. Log the logical job ID when the request arrives and when it is published to a queue. Record the request or event identity used by the caller and producer.
  2. Record every delivery and execution. At the worker, log the logical job ID, attempt number, queue message ID and receive count, and workflow ID and run ID where applicable. Do not treat any one of those platform-generated IDs as a substitute for the stable logical job ID.
  3. Log checkpoint and completion boundaries. Record when persisted state is read and written, and whether the write completed before the process stopped. Establish whether recovery resumed the same execution from recorded history or launched a fresh one.
  4. Instrument each external tool call. Log the logical job ID, idempotency key, request outcome, and any external operation ID returned by the tool or API. Avoid logging secrets or sensitive payloads.
  5. Compare the traces. Two producer submissions point toward the caller or producer. One submission with multiple deliveries points toward queue redelivery. Multiple workflow starts point toward start-request identity. One attempt with two external effects points toward the tool boundary or its response handling.
  6. Check timeouts and acknowledgements. Compare actual processing duration and batch window with the configured visibility timeout. Confirm successful messages were acknowledged or deleted, and check that partial-batch failure reporting behaves as intended.

Agent workflows also need explicit state management: record enough durable progress to recover meaningfully, while treating external actions as independently fallible. AWS’s agentic-AI guidance covers checkpoint-based recovery as part of state management. AWS Well-Architected Agentic AI Lens: Implement comprehensive state management and checkpoint-based recovery

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make retries safe at the side-effect boundary

Give each intended side effect a stable idempotency key derived from the logical operation, and reuse that key on every retry of that operation. The receiver should persist the key and the outcome together, then return the stored outcome when the same key arrives again instead of performing the action again. AWS describes idempotency as an operation whose effect remains the same regardless of how many times it runs. AWS Durable Execution SDK: Idempotency and retries

Scope keys to the action, not merely to an entire multi-step job. If one agent job legitimately sends a notification and creates a record, those are separate effects and may need separate keys. Keep the key stable across retries but distinct for a genuinely new intended action. Where practical, persist the result and completion state atomically in the system that owns the deduplication record.

Rank #4
The Manager's Red Book - Request Days Off logbook/notebook/planner, 8.5"x11" semi-annual, 118 pages, 8 lines per day (F2835) (July 2026 - December 2026)
  • Manage your employees' requests for days off in this 6-month, dated logbook / notebook
  • Includes annual, monthly, and holiday calendars with space for 8 entries per day
  • Pages and labeled monthly tabbed dividers are 8.5 x 11 inches.
  • Front and back covers are UV coated for water resistence, providing needed durability
  • Bound with durable plastic coil so book lays conveniently flat when open. Made in the U.S.A.

If a third-party tool does not accept idempotency keys, a local checkpoint cannot guarantee that the remote action happened only once. Reconcile by querying the external system for the intended result before retrying, or define a compensating action for duplicates when the business process allows it. For irreversible effects, design the recovery path before enabling automatic retries.

Test the failure window that causes duplicates

In a safe test environment, simulate the uncertain-outcome case: allow the external action to succeed, then interrupt the worker before it records local completion. On retry, verify that the receiver returns the stored outcome or that reconciliation safely detects the existing action. The intended result is no repeated irreversible effect. A test that only kills the process before the tool call does not exercise this boundary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose a recovery pattern for the workflow

No one orchestration pattern eliminates the need to protect external side effects. Choose based on workflow duration, failure modes, integrations, language and runtime, and the operational capacity of the team.

Best Value
Heveboik Income & Expense Log Book - A4 Income and Expense Tracker for Small Business, Accounting Bookkeeping Tracking for Woman and Man, 8" x 10.5", Pink
  • EASY TO MANAGE - Use this income & expense log book to record your income and expenses each day.Keep your budget in balance, and develop good bookkeeping habits to meet your financial goals
  • ACCOUNTING FOR THE WHOLE YEAR - This account ledger notebook is undated and is used to lasts a whole year.The keeping log has 1 page Year Overview, 53 weekly spreads, 2 pages annual summary, 10 notes pages, to track weekly and yearly income & expenses
  • HIGH QUALITY - The accounting bookkeeping tracking ledger log book is used to high quality 100gsm pure white paper, teal elastic band and a back pocket for extra space. Make sure you have enough space for all financial activities
  • UNIQUE DESIGN & A4 SIZE - Income and expense log book cover is lovely, golden spiral bound design, size of 8" x 10.5". Just the perfectly size to fit in your backpack, purse or laptop case. Without taking up your space and always helping you keep track of your small business
  • THE PERFECT GIFT - Income & expense notebook as gift for woman & man. Use it to track your week-to-week progress, make efficient adjustments whenever needed
Pattern Where it fits What to evaluate
Queue plus idempotent handler Event-driven jobs and systems that already use queues. Delivery and acknowledgement behavior, visibility timeout, deduplication-store consistency, dead-letter handling, and the work of operating the state store.
Cloud state machine or orchestrator Workflows where explicit branching, state transitions, and retry policies are useful. Service-specific retry behavior, execution history, limits, integrations, and idempotency of every external operation.
Durable code-first workflow engine Long-running work that needs recovery across process or infrastructure failures. Activity idempotency, history and replay constraints, operating model, language support, and managed-service costs. Temporal documents its task and workflow behavior; the OpenAI Agents SDK documents durable runs across waits, retries, and process restarts.
Manual checkpointing Simpler jobs where a small number of explicit recovery points are manageable. Checkpoint boundaries and whether completion can be persisted atomically with results. A checkpoint does not make a separate external system’s effect exactly once.

For durable code-first runs, see the OpenAI Agents SDK: Running agents. For Temporal’s documented partner ecosystem and cloud setup, see Temporal Partners, Temporal Cloud onboarding, and Temporal on AWS. These pages describe technical integrations and onboarding, not a guarantee that a particular workflow will meet your reliability, cost, or operational requirements.

What a clean restart can—and cannot—prove

A clean restart can show that the process came back; by itself, it cannot establish whether a caller submitted twice, a queue redelivered, a workflow replayed a step, or an external action completed before its result was recorded. Use the logical job ID to find the duplicate boundary, then enforce idempotency where the effect occurs. Checkpoints and durable history improve recovery, but the side-effect owner must still be able to recognize and safely handle a repeated request.

Quick Recap

Bestseller No. 1
Express Schedule Free Employee Scheduling Software [PC/Mac Download]
Express Schedule Free Employee Scheduling Software [PC/Mac Download]
Simple shift planning via an easy drag & drop interface; Add time-off, sick leave, break entries and holidays
Bestseller No. 2
Teacher Record Book
Teacher Record Book
Keep track of everything from attendance to test scores; Spiral bound; Measures 8-1/2" x 11"
$4.89
Bestseller No. 3
Adams Job Work Order Book, 3-Part Carbonless, White/Canary/White, 5-9/16 x 8-7/16 Inches, 33 Sets (T5868)
Adams Job Work Order Book, 3-Part Carbonless, White/Canary/White, 5-9/16 x 8-7/16 Inches, 33 Sets (T5868)
QUALITY FORMS: Adams Repair Order books provide space for costs in materials and labor; BACK PRINTING: Forms include space on the back to record materials used in the repair
$8.36
Bestseller No. 4
The Manager's Red Book - Request Days Off logbook/notebook/planner, 8.5'x11' semi-annual, 118 pages, 8 lines per day (F2835) (July 2026 - December 2026)
The Manager's Red Book - Request Days Off logbook/notebook/planner, 8.5"x11" semi-annual, 118 pages, 8 lines per day (F2835) (July 2026 - December 2026)
Manage your employees' requests for days off in this 6-month, dated logbook / notebook; Includes annual, monthly, and holiday calendars with space for 8 entries per day
$36.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

AI agentsIdempotencymessage queuesReliability Engineeringworkflow orchestration

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.