The model writes the answer, code delivers it
You ask your agent a question in a team thread. It starts working, and then a deploy replaces the task that was running it. Nothing is posted. The thread shows your question and nothing else, and you can’t tell a slow answer from a dead one. On Agent Core, the post that asked kept its 👀 forever.
What the article argues
Anthropic’s How we built our multi-agent research system has a section on running agents in production. Its point is short: “Agents are stateful and errors compound.” A run holds state across many tool calls, so a small failure can end it badly, and a deploy can catch an agent anywhere in its process. The article’s answer is to combine the model’s adaptability with deterministic safeguards, such as retry logic and checkpoints, and to let the model handle what it handles well, such as adapting when a tool fails.
We applied the same split to delivery. The model writes text. Code decides where it goes, how a retry works, what an unknown result means, what the asker sees when a run fails, and when nothing is posted.
What we changed
Code posts the reply
I gave the reply to code. No tool posts it. When a run started from a Comms post ends, code reads the stored run and decides:
| Run ended by | Reply |
|---|---|
| Completion | The answer |
| A cancel, the deadline, or another run error | The failure sentence |
| Completion with an answer the product refuses | The failure sentence |
| Completion, but a source is no longer readable at reply time | The failure sentence |
| A switch that stops the agent, a crash, a failed token | Nothing |
Before the first write, code saves the post’s ID with the run. Every retry sends the same text under the same ID, and Comms returns the existing post instead of a second one. So a run has at most one reply, and a lost response is safe to retry. When code can’t confirm the result, it records it as unknown, never as posted.
Just before posting, code checks the answer’s sources again with the asker’s access. A thread the asker lost, or a searched channel that turned private, gets the failure sentence instead of being copied into a post.
The post that asked shows the state
The asker had nothing to look at between asking and the reply. I put the run’s state on the post that asked, with reactions every Comms client already shows: 👀 when the run starts, then ✅ once the answer is posted or ❌ after a failure. ✅ or ❌ waits for the reply’s result, so a reply whose result is unknown gets neither.
The 👀 stayed after the run ended, next to the ✅, so a finished run still looked busy. Agent Core had never removed a reaction. I made code take the 👀 back once the final reaction is confirmed, so the post never loses every mark. That needed a Comms backend change that lets Agent Core remove only its own reaction, only on the post that asked. The asker’s own 👀 stays.
Fixed sentences for failures
A failed run often has no model output to post, and the asker can’t act on the cause anyway. I settled three situations where @todoist can’t answer (trimmed):
| Situation | Before | After |
|---|---|---|
| The run failed or was refused | Sorry, I couldn’t finish an answer to this. Please ask again. | Sorry, I couldn’t finish an answer this time. Please try again, or ask about a specific thread or topic. |
| No search found the answer | Two to four sentences, different every time | I couldn’t find where the dragon egg is hidden in this thread or in the public channels you’ve joined (…). Name a person, project or channel and I’ll look again. |
| The thread is too long | Partial answer. The run stopped reading to stay within its model budget. (…) | This is longer than I can read in one go. (…) Ask about a specific part or topic and I’ll read that. |
The first is a constant in code. The not-found answer is still written by the model, so the prompt gives it a fixed two-sentence shape instead of a description. The long-thread opening is a line code writes before the model’s partial answer. On the evaluation set, 3 runs per case, the expectation pass rate went from 87% to 100% for empty searches, 67% to 100% for incomplete threads, and 75% to 100% for answers near the budget.
Two later changes made the failure sentence fit the reader. In a thread, “Sorry, I couldn’t finish” helped nobody but the asker, and the ❌ already told everyone else. I sent it to the asker alone, in their direct message with @todoist, with a link back to the question. Then a model provider outage showed the sentence’s advice was wrong: rephrasing changes nothing when the provider is down. I added a second fixed sentence for a provider timeout or an error not known to repeat. The Comms reply test pins both texts, as posted in the asker’s direct message:
❌ Sorry, I couldn't finish an answer this time. Please try again, or ask about a specific thread or topic.
Your question: comms-thread://<thread>/c/<comment>
Sorry, my brain froze while I was working on your answer. Give me a few minutes, then ask me again.
Your question: comms-thread://<thread>
Neither names the provider: no model text or provider message reaches the reply. Code also records which rule refused an answer, without the answer itself, which Measure failures where the model sees them covers.
When a deploy stops a run
Back to the opening example. A deploy stopped the task, the run ended with run_interrupted, and that code posts nothing by design: after a crash, the process that held the asker’s access is gone, so nothing can post. But an orderly stop still holds that access while the task shuts down.
The article solves this with rainbow deployments, keeping old and new versions running until runs finish. We didn’t go that far. I made a run caught by an orderly stop end with service_stopping, which posts the failure sentence and ❌ like a cancel. A crash or a lost service lock still ends silent.
The service test sends a trigger whose start is still in flight, then shuts the service down (trimmed, from the test, not a run):
expect(triggerRows[0]).toMatchObject({ status: 'failed', error_code: 'service_stopping' })
// A stopping task still owns the run's grant, so the asker learns to ask again.
expect(productReplies.posts.map(({ text }) => text)).toEqual([FAKE_FAILURE_SENTENCE])
expect(productReplies.reactions).toEqual([
{ post_id: 'shutdown-trigger', state: 'working' },
{ post_id: 'shutdown-trigger', state: 'failed' },
])
Knowing when not to answer
Every post that mentioned @todoist started a run, and every run got a reply. So a post that only told a colleague about @todoist still got an answer to a question nobody asked it.
I let the model decline, and kept the decision in code. Code decides, when it builds the prompt, whether a run may stay silent: only in a thread or a group chat, never in a one-to-one chat or a follow-up. For those runs, the prompt says (trimmed):
When the post is written to other people or only talks about you, and asks you
nothing, answer exactly NO_REPLY and nothing else; nothing is then posted. When it
asks you anything, answer it as usual. When you are unsure, answer.
Code compares the whole trimmed answer to the token. A run that wasn’t given the rule can never be silenced by an answer that happens to be NO_REPLY, and a run that stored a proposal or ended with a request always posts it. The prompt also forbids NO_REPLY after the run changed anything, but only the prompt enforces that. When the answer matches, nothing is posted, the post gets 👍, and the reply span records nothing_to_say.
An evaluation case plays a post like that in the Hogwarts workspace, started the way Comms starts a run for a post (trimmed):
id: post-asks-nothing-1-talks-about-the-agent
fixture:
threads:
- id: th-feast
title: Start-of-term feast
comments:
- creator: 303
content: 'The answers here repeat the same link in the source line.'
anchor:
kind: thread
object_id: th-feast
asker: 101
by_post: true
question: "[Severus Snape](comms-mention://303), feedback addressed: won't repeat a link in its source line any more."
expect:
must_say:
- ^\s*NO_REPLY\s*$
Its pair in the same thread, “when do the first years wait at the door?”, must answer “half past six” and must not say NO_REPLY. Evaluation cases are grouped into families by behaviour, and this new family has eight cases. Three runs each: the four posts that ask nothing answered NO_REPLY 12 of 12, the three that ask something were answered 9 of 9, and a thanks in a one-to-one chat was answered 3 of 3.
The same token came first for runs nobody asked for, such as an automation’s daily check-in that shouldn’t message its owner to say there’s nothing to report.
What I’d tell someone doing the same
- Keep the reply out of the model’s tools. Code can retry it safely, check it against the asker’s access at the last moment, and replace it with a failure sentence.
- Give each ending a visible state, including the silent ones. Only a crash or a stopped agent leaves the 👀 behind, because nothing is left to take it back.
- Write failure messages as constants, and split them by what the reader can do. “Ask differently” and “ask again later” are different instructions.
- Let the model say “nothing to say”, but decide in code where it may.
The trade-off is risk in the other direction. The model can answer NO_REPLY to a post that did ask it something, and then the asker gets no answer and no ❌. A run that changed something and then answers NO_REPLY would stay silent too. We accepted both risks for threads and group chats, kept the prompt’s “when you are unsure, answer”, and kept one-to-one chats out of it entirely.