Skip to content

feat(runtime): Add idempotency key support to prevent duplicate webhook executions#5954

Closed
namo507 wants to merge 1 commit intoaden-hive:mainfrom
namo507:patch-4
Closed

feat(runtime): Add idempotency key support to prevent duplicate webhook executions#5954
namo507 wants to merge 1 commit intoaden-hive:mainfrom
namo507:patch-4

Conversation

@namo507
Copy link

@namo507 namo507 commented Mar 6, 2026

Summary

Documents the webhook idempotency gap in trigger() and tracks the full implementation. Addresses #5947.

Changes

Related issue: Closes #5947

The problem

AgentRuntime.trigger() has no deduplication. Webhook providers (Stripe, GitHub, etc.) retry on timeout/5xx — without idempotency, a single event can spawn multiple execution streams, each making API calls, sending emails, and mutating state.

Implementation plan

  1. Add idempotency_key: str | None = None param to trigger()
  2. Initialize self._idempotency_cache: OrderedDict[str, tuple[str, float]] in __init__
  3. On trigger(): check cache → return existing execution_id if key seen within TTL
  4. For webhook routes: auto-generate key by hashing method + path + body
  5. Lazy cleanup: sweep expired keys on each insert

Test plan

  • Same idempotency key within TTL returns same execution_id
  • Same key after TTL expiry starts new execution
  • Auto-generated key from webhook payload produces stable hashes
  • Cache doesn't grow unbounded (verify cleanup on insert)
  • Stripe-style triple retry triggers only one execution

…duplication

- Adds a TODO(feat/webhook-idempotency) comment in agent_runtime.py marking the missing deduplication logic
- Documents the required fix: idempotency_key param, OrderedDict TTL cache, auto-hash fallback
- References issue aden-hive#5947
- Resolves: aden-hive#5947 (tracking comment)
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

PR Closed - Requirements Not Met

This PR has been automatically closed because it doesn't meet the requirements.

PR Author: @namo507
Found issues: #5947 (assignees: none)
Problem: The PR author must be assigned to the linked issue.

To fix:

  1. Assign yourself (@namo507) to one of the linked issues
  2. Re-open this PR

Exception: To bypass this requirement, you can:

  • Add the micro-fix label or include micro-fix in your PR title for trivial fixes
  • Add the documentation label or include doc/docs in your PR title for documentation changes

Micro-fix requirements (must meet ALL):

Qualifies Disqualifies
< 20 lines changed Any functional bug fix
Typos & Documentation & Linting Refactoring for "clean code"
No logic/API/DB changes New features (even tiny ones)

Why is this required? See #472 for details.

@github-actions github-actions bot closed this Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add idempotency key support for webhook-triggered executions to prevent duplicates

1 participant