Balance: when agents stop and how they come back

Your workspace pays for your agents from one balance. It starts with $5 of credit. This page is what happens when the balance runs low or goes below zero, what your customers see then, what the API returns, and how the agents get back to work after a top-up.

Before zero: the $1 notices

When a charge takes the balance under $1, Flutch tells the workspace owner in the console notifications, by email and in Telegram, if Telegram is linked. The console shows the banner Your balance is running low. While the balance stays under $1, the reminder comes once a day. The agents keep answering as usual.

You can change the amount in Notifications → Low balance → Threshold, $. Add funds in Billing → Add funds.

Below zero: the agents stop

As soon as the balance goes below zero, every agent of the workspace stops before it generates a reply. This includes agents with your own model key and agents on your own code: Flutch does not call your endpoint. The owner gets Your agents have stopped replying right away, and then once a day while the balance stays below zero. The console shows the red banner Agents are not answering customers.

Each customer message that arrives in this state is handled like this:

  1. The message is saved in the conversation.
  2. The conversation is handed to your team with the reason insufficient_funds, and the agent's owner or escalation recipient gets the usual hand-over notification.
  3. The customer gets no reply from the agent. A public comment never gets a service reply.

The next messages of the same customer stay with your team, like in any hand-over. Your team can answer them from the Inbox.

What the API returns

On POST /api/v1/agents/{agentId}/stream, the stop comes as an escalated event before final:

event: thread_created
data: {"threadId":"6b0b0093965d9efd2a6ccc25","requestId":"0d6f6c1e-3f2a-4b8e-9a51-2a4c0f1f5b7e"}

event: message_created
data: {"messageId":"6b0b0094965d9efd2a6ccc3a"}

event: escalated
data: {"reason":"insufficient_funds","hasStaticReply":false}

event: final
data: {"id":"6b0b0094965d9efd2a6ccc38","threadId":"6b0b0093965d9efd2a6ccc25","role":"user","status":"delivered","content":{"text":"Hi! Do you deliver on Saturdays?"}}

The final event here carries the customer's own message, with "role": "user", because there is no reply. The reply announced by message_created is removed. POST /api/v1/agents/{agentId}/invoke returns the same customer's message as its body. So check the role of what you get back before you show it as the agent's answer.

reason in the escalated event is one of:

reasonWhen
insufficient_fundsThe balance is below zero, this message stopped the agent
thread_already_escalatedThe conversation is already with your team, for example the next messages after insufficient_funds
generation_errorThe agent failed to answer, the conversation went to your team
no_lead_creditsAn agent paid per lead has no lead credits left

The fields of the final message are described in Agent API.

After a top-up

When a top-up brings the balance back to zero or above, the conversations that stopped with insufficient_funds go back to their agents right away. The agent answers the customer's next message. The message that arrived while the balance was below zero stays without an agent reply, so if it matters, answer it from the Inbox.

Conversations where someone from your team has already replied stay with the team. They come back when someone clicks Return to agent, or after 30 minutes without a reply from the team, as in any hand-over: see Instagram: the 24-hour window and handing a chat to a person. Hand-overs for other reasons, such as generation_error, also stay with the team.