Most agents answer in seconds, and it is convenient to call them like a function: send a request, wait for the answer. Market research in our analytical agent takes 4 to 10 minutes, and a full report takes 15 to 20. In that time the agent calls other agents, the user has time to switch to another chat, and the service may be restarted.
A function call does not fit this kind of work. We model long work as a task: it has an owner, a status, a stored result and a cancellation that reaches every participant. Below is what breaks without this and how it is built.
A timeout on the waiting side does not stop the work
The least obvious problem is timeouts. An agent calls another agent and waits fifteen minutes. Time runs out, the waiting side gets an error, and the called agent does not know about it and keeps working. If the waiting side decides to retry, the work runs twice. That is how one of our reports was started ten times in a single night.
The same problem has a side that involves the user. If switching to another chat cancels the request, a person who did not wait for the answer and went to look at another conversation loses the answer. If it does not cancel, the work keeps going even when nobody is waiting for it. You have to decide explicitly what cancels the work and what merely disconnects from it.
A task instead of a call
Our tool for calling agents has two modes. In the normal mode the agent waits for the answer. In task mode it starts the work and gets its id, and then asks for the status, picks up the result or cancels the task.
The backend manages the tasks. A running task reports every 15 seconds that it is alive. If it is silent for a minute, the backend considers it lost. If nobody asks for the result for a minute and a half, the task is considered abandoned and is cancelled, so that no money goes on an answer nobody needs. A finished result is kept for a day.
Cancellation runs along the whole chain. When the user presses Stop, the platform stops the run on whichever instance of the service it is running on, and the called agents and tools receive the cancellation after it. The SDK passes the cancellation signal into every tool call, so there is nothing to write for it in the graph's code.
Service restarts
Long work should not live only in the memory of one process. A report in the analytical agent is written as a job in the database: the job has a current worker and a lease that the worker renews regularly. If the service is restarted, the lease expires and another instance picks up the job. Sections already written are kept, and only what is missing gets written.
What the user sees
Silence in the chat for several minutes looks like a failure. So research shows its plan as a checklist from the first second, the agents post short notes about what they are looking for right now, and the report card first shows a loading indicator and then turns into a link. During long pauses the SDK sends heartbeats into the stream, and the API lets a client reconnect to a message's stream if it lost the connection.
What it costs us
Tasks are more complex than calls. A task has states, and each of them has to be handled: running, lost, abandoned, cancelled, done. The rule about a minute and a half without reading protects against unnecessary spending but turns into a trap: if the agent that started a task does not check it regularly, the task dies while the agent is busy with something else. Our graph has a separate mechanism for this that reads the running tasks every 30 seconds.
There are infrastructure surprises too. Reasoning models sometimes think for more than a minute before the first token, and the default idle timeout on many load balancers is exactly 60 seconds. Our model calls were cut off at exactly the sixtieth second, six times in a row, until we moved the traffic to the model router inside the cluster.
The opposite mistake
Once you decide that tasks are more reliable, it is easy to turn everything into a task. But a short answer that takes a few seconds is better left as a normal call: a task adds the delay of polling for status and several states that have to be handled. Task mode is off by default in our platform and is turned on only for agents that know how to keep their tasks alive.
What's next
In Flutch, tasks, chain-wide cancellation and stream heartbeats work for all agents on the platform. If you are building long-running agents yourself, answer three questions in advance: what exactly cancels the work, what happens to the work when the service restarts, and what idle timeout sits on every proxy between the agent and the model.