# Failures and scaling

> What happens when the agent, a product, PayPal or a notification fails, and how App grows.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://app.docs.sypnia.com/architecture/failures-and-scaling/

For agents: Failures: Agent unavailable → message saved, «the agent is not answering; your message is kept», retried with backoff for 10 min, then the session offers Retry; stream drop → resume from Last-Event-ID; product down → board card shows last known values with read_at, chat says which product is not answering; PayPal confirmation late → capture result credits; if neither arrives the top-up stays waiting and is checked again every 5 min for 24 h, then failed (no credits, no charge kept); ledger writes are idempotent by key; notifications failing → retried, then e-mail; DLQ alarm. Scaling: stateless API (Lambda), streams per message, Postgres the only state; board cache 60 s; per-session message rate limit.

| When                                   | What happens                                                                                                                         |
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| **The agent does not answer**          | your message is kept; App says so and tries again for 10 minutes, then offers **Retry**                                              |
| **The connection drops mid-answer**    | the interface reconnects and continues from the last part it received                                                                |
| **A product does not answer**          | its board card shows the last known values and when they were read; the chat says which product is not answering                     |
| **PayPal's confirmation is late**      | the capture result adds the credits; if neither arrives, App checks again every 5 minutes for 24 hours, then marks the top-up failed |
| **A product reports spending twice**   | the ledger writes each entry once, by its key                                                                                        |
| **A notification cannot be delivered** | it is retried, then sent by e-mail                                                                                                   |
| **Messages pile up in a queue**        | a dead-letter queue keeps them and raises an alarm                                                                                   |

## Scaling

The API holds no state between requests; Postgres is the only state. Each answer is its own stream. The board's 60-second cache and the limit of messages per session keep one busy project from slowing others.
