Skip to content

api/sdk: optional Idempotency-Key support for messaging writes#5

Merged
khaliqgant merged 4 commits into
mainfrom
add-idempotency-keys
Feb 9, 2026
Merged

api/sdk: optional Idempotency-Key support for messaging writes#5
khaliqgant merged 4 commits into
mainfrom
add-idempotency-keys

Conversation

@willwashburn
Copy link
Copy Markdown
Member

@willwashburn willwashburn commented Feb 8, 2026

Summary

  • add server-side idempotency handling via Idempotency-Key for write endpoints:
    • POST /v1/channels/:name/messages
    • POST /v1/messages/:id/replies
    • POST /v1/dm
    • POST /v1/dm/:conversation_id/messages
  • introduce shared middleware helper (runIdempotent) backed by Redis with:
    • replayed response return + Idempotency-Replayed: true
    • conflict on same key with different payload (409 idempotency_key_reused)
    • conflict while in-flight (409 idempotency_in_progress)
    • graceful degradation when Redis methods are unavailable
  • extend SDK HTTP client to accept per-request headers and expose optional idempotencyKey on agent messaging APIs (send, reply, dm, dms.sendMessage)
  • add server middleware tests and SDK header-propagation tests
  • document idempotency usage in README authentication section
  • include existing .gitignore update (.npm-cache) per request

Validation

  • npm --prefix /Users/will/Projects/relaycast/packages/server test -- src/middleware/__tests__/idempotency.test.ts src/routes/__tests__/message.test.ts src/routes/__tests__/dm.test.ts src/routes/__tests__/thread.test.ts src/routes/__tests__/groupDm.test.ts
    • passed (33/33)
  • npm --prefix /Users/will/Projects/relaycast/packages/sdk test -- src/__tests__/agent-messaging.test.ts
    • passed (23/23)

Open with Devin

@khaliqgant khaliqgant self-requested a review February 9, 2026 08:57
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment thread packages/server/src/middleware/idempotency.ts Outdated
Comment thread packages/server/src/middleware/idempotency.ts
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 9 additional findings in Devin Review.

Open in Devin Review

Comment thread packages/server/src/middleware/idempotency.ts
@khaliqgant khaliqgant merged commit bf9e154 into main Feb 9, 2026
1 check passed
@khaliqgant khaliqgant deleted the add-idempotency-keys branch February 9, 2026 09:21
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.

2 participants