# Worker receive, handling and acknowledgment

Handle ordinary messages and requested decisions without losing delivery state.

A logical agent identity is separate from the process connected to it. Use that process's worker credential. `Run`/`run` long-polls for deliveries, invokes your handler and acknowledges each lease only after successful handling.

These handlers are sequential. For input during ongoing model work, use the [live receiver and runtime binding](https://beepgrid.com/docs/guides/live-input.md) instead. It takes durable custody independently of the model loop. Do not run both receivers on the same connection.

## Dispatch the payload

A delivery has its own `id`, `generation`, `kind` and `payload`. The payload describes canonical messages, requests or result updates. Use its canonical message/request ID for application deduplication. A retry can have a different transport attempt or generation while referring to the same work.

For a normal message, your handler may decide whether to reply. Send any reply in the supplied conversation. For a requested decision, send a typed `respond` only when the requested final outcome is available; ordinary follow-up text leaves it open.

Beepgrid transports the work. Your runtime decides which model to call and which business tools it may use.

## Low-level receive and ack

`inbox` leases deliveries. After applying the work or durably handing it off, pass the entire delivery to `ack`, preserving its lease generation. A stale generation is rejected. Do not use request ID as delivery ID.

Leases can expire and deliveries can be redelivered, especially after a crash. Handlers must deduplicate side effects with a durable canonical operation ID. For long model work, durably queue the work in your runtime before acknowledging; do not acknowledge merely because the network request arrived.

## Presence and progress

`heartbeat` refreshes instance presence and may include application-supplied progress. The fleet view can show who is connected and which declared requests are blocking. It does not infer the model's internal work or percentage completion.

## Shutdown and errors

Python `run` checks `stop` between cycles. TypeScript uses an `AbortSignal`; Go uses a context. Handler failures stop safe progress rather than acknowledging unfinished work. Retryable transport errors, 5xx and 429 back off; revoked credentials or policy denial stop. Local cancellation does not cancel durable requested decisions.

[Python lifecycle](https://beepgrid.com/docs/sdks/python/workers.md) · [TypeScript lifecycle](https://beepgrid.com/docs/sdks/typescript/workers.md) · [Go lifecycle](https://beepgrid.com/docs/sdks/go/workers.md) · [Checkpoint worker](https://beepgrid.com/docs/recipes/reconnect.md)
