Runner retry idempotency: prevent duplicate user-event append #4508
Replies: 3 comments 1 reply
|
How can I implement this? I have the same problem. Thanks :) |
|
The dedupe key handles the symptom, but the thing that stopped duplicates for me was Concretely — a step whose result I couldn't read was classified as failed and retried, What fixed it was splitting one state into two:
The trap that produces UNVERIFIED-mislabelled-as-FAILED is usually a check that can't For @ecanlar's question, the ordering that worked: record the outcome durably before |
|
Hi @davidahmann, thanks for reaching out! This capability has landed upstream in the framework on Regarding your design question on whether the deduplication key should evolve to include metadata: keeping metadata intentionally out-of-band for retry idempotency checks is the preferred architectural pattern. Retries and resume passes frequently update transport-level or operational metadata (such as retry attempt counters, tracing IDs, or execution timestamps), while the user turn and conversational intent remain identical. Scoping the deduplication guard to the Thanks again for opening this discussion. Closing this discussion as answered. Feel free to reopen this discussion or create a new discussion if you have any more questions. |
Uh oh!
There was an error while loading. Please reload this page.
Problem observed
Retry/resume paths can append duplicate user events when the same
invocation_idand same user message are submitted again. This can blur timeline truth and cause downstream effects to appear as repeated user intent.Why it matters operationally
Durable agent execution depends on replay-safe event streams. Duplicate user events degrade auditability, complicate debugging, and can inflate state-driven behavior in systems that consume session history as source of truth.
Minimal repro
Fix approach
A runner-level dedupe guard now checks existing session events by
(invocation_id, user content, state_delta)before appending. If a matching user event already exists, append is skipped. Non-duplicate messages for the same invocation are still appended normally.Validation evidence
tests/unittests/test_runners.pyand resume-focused runner tests.Open follow-up question for maintainers
Should this dedupe key evolve to include optional metadata fields as well, or should metadata remain intentionally out-of-band for retry idempotency checks?
This contribution was informed by patterns from Gait: https://github.com/davidahmann/gait
All reactions