# Kafka runtime guarantees

> What @kafka_workflow and @kafka_agent guarantee in each delivery mode.

Source: https://docs.pyrula.io/workflows/guides/kafka-guarantees/

The Kafka runtime provides exactly-once *processing* and at-least-once *output delivery*
by default. `@kafka_agent` uses the same runtime contracts as `@kafka_workflow` with an
additional LLM loop.

`yes` means the guarantee holds, `partial` that it holds within a boundary and `no` that it
does not. Output delivery is `partial` unless the binding uses `delivery="exactly_once"`: a
crash between produce and commit re-produces on redelivery, so dedupe downstream on key.
`durable=False` has no run store, so the handler re-runs on every retry or redelivery.

| Binding | processing | output delivery | poison | handler error |
|---|---|---|---|---|
| `kafka_workflow` | yes | partial | yes | yes |
| `kafka_workflow[exactly_once]` | yes | yes | yes | yes |
| `kafka_workflow[durable=False]` | no | partial | yes | yes |
| `kafka_agent` | yes | partial | yes | yes |
| `kafka_agent[exactly_once]` | yes | yes | yes | yes |

## Install and tested versions

All bindings: built in. Supported brokers: Kafka 3.9+ (tested on 3.9 and 4.4), Confluent Platform 7.9+.

## Runner behavior

- A failed produce, offset commit or aborted transaction rewinds the partition to the
  uncommitted offset and retries with a backoff. A fatal error, or eight failures in a row,
  stops the runner and `run()` raises `KafkaRunnerError`.
- A rewind re-runs the handler for the whole drain, so a failing record repeats its handler
  attempts on each retry.
- `on_error="fail"` stops the runner's worker, not only the one record.
