kafka-agent-bridge
kafka-agent-bridge is a small Python library for developers who already know LangGraph or CrewAI and want Kafka to be the event bus without hand-rolling consumers, retries, idempotency, result publishing, and dead-letter handling. It fills the space between heavyweight streaming-agent platforms and raw framework glue code.
Quickstart
pip install -e '.[langgraph,redis,dev]'
docker compose up
from kafka_agent_bridge import KafkaAgentBridge
from kafka_agent_bridge.adapters import LangGraphAdapter
adapter = LangGraphAdapter(graph=compiled_graph)
bridge = KafkaAgentBridge(
bootstrap_servers="localhost:9092",
consumer_group="reports-agent",
idempotency_backend="redis://localhost:6379",
)
bridge.register(
topic="reports.requested",
handler=adapter,
adapter="langgraph",
output_topic="reports.completed",
dlq_topic="reports.dlq",
)
await bridge.start()
Run the included LangGraph example:
make dev
make example-fraud
Kafka UI is available at http://localhost:8080.
Architecture
Kafka topic
|
v
KafkaAgentBridge
|-- JsonDeserializer -> EventEnvelope
|-- AgentRouter -> topic glob, X-Agent-Type, predicate
|-- IdempotencyGuard -> Redis or in-memory TTL cache
|-- LangGraphAdapter / CrewAIAdapter / custom handler
|-- KafkaResultProducer -> output topic
|
+-- DeadLetterQueue -> *.dlq after retries
LangGraph graphs can use KafkaCheckpointer:
thread_id -> compacted Kafka topic agent.checkpoints
What Is Included
KafkaAgentBridgeasync runtime with multiple topic registrations.AgentRouterwith glob, header, and predicate routing.KafkaResultProducerwith JSON serialization and configurable batching.EventEnvelopePydantic model for consumed messages.- Redis-backed or in-memory idempotency guard.
- Retry and dead-letter publishing.
LangGraphAdapter,CrewAIAdapter, andKafkaCheckpointer.- Docker Compose with Kafka, Redis, and Kafka UI.
Avro and Schema Registry support are intentionally stubbed for v0.2.
Comparison
| Approach | Best For | Tradeoff | How It Is Handled |
|---|---|---|---|
| kafka-agent-bridge | Python teams wiring LangGraph or CrewAI into Kafka quickly | Lightweight v0.1 surface; advanced Kafka tuning remains explicit | Sensible defaults cover the common path, while consumer_kwargs, producer_kwargs, retry settings, DLQ topics, and idempotency backends stay configurable when a production workload needs them. |
| Confluent Streaming Agents | Teams already on Confluent's managed ecosystem | More platform coupling and operational surface area | Use it when managed Confluent services are already the standard; use this library when teams want a smaller OSS Python layer over plain Kafka. |
| Hand-rolling | Highly custom Kafka and agent orchestration needs | Rebuilds routing, retries, DLQ, idempotency, and checkpointing yourself | Start with this library for the repeated plumbing, then drop down to custom handlers, predicates, adapters, and raw Kafka kwargs where the workflow genuinely needs custom behavior. |
The intent is not to hide Kafka forever. The bridge makes the default path small, then leaves explicit escape hatches for teams that need partitioning, offset, batching, security, or consumer-group tuning.
Local Development
python -m venv venv
venv/bin/pip install -e '.[all,dev]'
make test
make lint
Contributing
Issues and pull requests are welcome. For now, keep contributions focused on small, well-tested improvements: adapter behavior, Kafka operational safety, examples, and documentation. Please include tests for behavior changes and keep public APIs typed and documented.
Metadata
Release files for kafka-agent-bridge 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kafka_agent_bridge-0.1.0.tar.gz | 19.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kafka_agent_bridge-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.9 kB
Release files / kafka_agent_bridge-0.1.0.tar.gz
| Download URL | kafka_agent_bridge-0.1.0.tar.gz |
|---|---|
| Size | 19.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80c75e645fe27a07aed6514e20c4e3fc904e3a9de0573d6fd0ef468c7e9f1db3
|
|
BLAKE2b-256 checksum How to use checksums |
33ccb5aa970cf3ee1b5b3060cc4e80173b95f416e0ca58a8d0883b606bb24ca2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / kafka_agent_bridge-0.1.0-py3-none-any.whl
| Download URL | kafka_agent_bridge-0.1.0-py3-none-any.whl |
|---|---|
| Size | 20.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee1cde562659e67760d1da5b5cd8fe7c8a13db1965dd77511c3df38b76faf7f6
|
|
BLAKE2b-256 checksum How to use checksums |
1a7b5b8b9665ac8f113dff43d53448f2e5ed3496d1f768f0040f1ff41f25f5ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|