Skip to content

API Reference parrot.integrations.slack.dedup

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.integrations.slack.dedup

View source

Event deduplication for Slack integration.

Slack retries event delivery if it doesn't receive HTTP 200 within ~3 seconds. Without deduplication, the same message can be processed multiple times, causing duplicate agent responses. This module provides both in-memory and Redis-backed deduplication strategies.

Attribute DeduplicatorType

Class EventDeduplicator

In-memory event deduplication with TTL.

For single-instance deployments. Use RedisEventDeduplicator for multi-instance production environments.

Parameter Type Default Description
ttl_seconds int 300 Time-to-live for seen events (default: 300 seconds / 5 minutes).
cleanup_interval int 60 How often to run cleanup (default: 60 seconds).

Attributes:

Attribute Type Description
seen_count int Return the number of events currently tracked.

Method EventDeduplicator.start

Start the background cleanup task.

start() -> None

Method EventDeduplicator.stop

Stop the cleanup task.

stop() -> None

Method EventDeduplicator.is_duplicate

Check if event was already seen. Thread-safe for sync contexts.

is_duplicate(event_id: Optional[str]) -> bool

Parameter Type Default Description
event_id Optional[str] The Slack event ID to check.

Returns: bool — True if the event was already processed, False if new or empty.

Method EventDeduplicator.clear

Clear all tracked events. Useful for testing.

clear() -> None

Class EventDeduplicatorProtocol

Protocol for event deduplication backends.

Both in-memory and Redis-backed implementations follow this interface.

Method EventDeduplicatorProtocol.is_duplicate

Check if an event has been seen before.

is_duplicate(event_id: str) -> bool

Parameter Type Default Description
event_id str The Slack event ID to check.

Returns: bool — True if the event was already processed, False otherwise.

Method EventDeduplicatorProtocol.start

Start the deduplicator (e.g., cleanup tasks).

start() -> None

Method EventDeduplicatorProtocol.stop

Stop the deduplicator and clean up resources.

stop() -> None

Class RedisEventDeduplicator

Redis-backed deduplication for multi-instance deployments.

Uses Redis SET NX with TTL for atomic deduplication across multiple application instances.

Parameter Type Default Description
redis_pool An async Redis client/pool (aioredis or redis-py async).
prefix str 'slack:dedup:' Key prefix for deduplication keys (default: "slack:dedup:").
ttl int 300 Time-to-live in seconds (default: 300).

Method RedisEventDeduplicator.is_duplicate

Check if event was seen using Redis SETNX.

is_duplicate(event_id: Optional[str]) -> bool

Parameter Type Default Description
event_id Optional[str] The Slack event ID to check.

Returns: bool — True if the event was already processed, False if new or empty.

Method RedisEventDeduplicator.start

No-op for Redis (connection managed externally).

start() -> None

Method RedisEventDeduplicator.stop

No-op for Redis (connection managed externally).

stop() -> None

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally