A scheduled agent run can fire twice when a timer overlaps or a retry happens, and a run that is not idempotent will do the work twice, sending two emails or creating two records. An idempotent run uses a fixed key, such as the date, and skips work already done under that key. Build the check in before the schedule goes live.
Checked on 2026-11-29. We did not run any tool for this guide. Every result below is an expected result, marked UNTESTED, for you to confirm on your own files.
Prerequisites
- A scheduled agent task that runs daily
- A place to record completed work, such as a log or a database
- The date key for the run, for example 2026-11-29
Steps
1. Give each run a date key
Set the run key to the date, for example daily-summary-2026-11-29, so a repeat has the same key.
Expected result: A date key format is set and written down.
2. Check the key before acting
At the start of the run, check whether the key already has a completed record. If it does, stop.
Expected result: The check runs before any action, and a repeat stops with a note.
3. Record completion under the key
When the run finishes, record the key as done, with the time and the result.
Expected result: A completion record exists under the date key.
4. Test with a forced repeat
Run the task twice in a row with the same key and confirm the second run does nothing.
Expected result: Two runs with the same key produce one set of actions, not two.
Worked example
A practice daily summary ran twice on 2026-11-29. The second run saw the key and stopped.
| Run | Key | Actions taken |
|---|---|---|
| Run 1 | daily-2026-11-29 | 3 |
| Run 2 | daily-2026-11-29 | 0 |
| Run 3 | daily-2026-11-30 | 3 |
| Totals | 6 |
Expected result: The first run takes 3 actions, the repeat takes 0, and the next day takes 3, so no work is doubled (UNTESTED – confirm it yourself.)
Verdict table
| Check | Expected result | Pass? |
|---|---|---|
| Give each run a date key | A date key format is set and written down. | – |
| Check the key before acting | The check runs before any action, and a repeat stops with a note. | – |
| Record completion under the key | A completion record exists under the date key. | – |
| Test with a forced repeat | Two runs with the same key produce one set of actions, not two. | – |
Limits
- Idempotency only works if every action checks the key; one unchecked action can still double.
- A failed run that recorded completion by mistake will be skipped next time; record completion only after success.
Sources
- Model Context Protocol (Stanford CS329T slides) – checked 2026-11-29
- The Model Context Protocol (MCP) for compliance data – checked 2026-11-29
- What is the Model Context Protocol (MCP)? – checked 2026-11-29
- Ollama v0.9.1 release notes – checked 2026-11-29
