Someone on X asked me a question I had been fighting with for weeks. He had one agent and several long-running Telegram threads, and now he had wired a voice assistant to it. Things got confusing. His idea: “I think I must create a ‘voice’ session that just communicates with other sessions… or make an orchestrator of the orchestrator.”
I understand the impulse. I've done something similar. But I think the problem isn't the number of sessions. It's that one word, “session”, is being asked to mean three different things. Once you separate them, most of the orchestration goes away.
This article is about those three things, as I built them into Mira, an open-source voice agent for Home Assistant. It also covers the two bugs that taught me where the lines must go, and how a remote agent like Hermes fits in without a second orchestrator. I'm assuming you've built an LLM agent with a chat history and tools. Home Assistant knowledge helps but isn't required. Mira speaks German in my house; I've translated every quote.¹
Three things called “session”
In a chat app, a session is simple. One person, one window, one history that grows until you start a new one. Everything sticks to the session because nothing about it changes.
Voice breaks every one of those assumptions. The room changes when you walk to the kitchen. The speaker changes when someone else answers. And the gap between two sentences can be five seconds or five hours, with no window that stays open in between.
So Mira separates three things:
| What it is | How long it lives | |
|---|---|---|
| Conversation | What Home Assistant calls a conversation: from the wake word to the end of listening, plus follow-ups that keep listening | Voice: 5 minutes without a new sentence. Telegram: no time limit, the history is trimmed instead (a command starts a new one) |
| History | The earlier turns the model sees, verbatim, with tool calls and results | As long as what it belongs to |
| Thread | One concern across turns and conversations: a goal, fields to fill, a log, optionally a plan, and an owner | Until it's done, cancelled or expired |
In the code and the database a conversation is still called session, for historical reasons. In this article, “session” means the vague thing we all say. The three words in the table are the precise ones.
The five minutes for voice aren't arbitrary. A new sentence a quarter of an hour later almost never connects to what was said before. If it does, it connects to a concern, “that appointment we talked about”, and concerns are what threads are for.
Whose history is it?
Before threads, there's a simpler question: when a sentence arrives, which history does the model see? Mira decides from the call itself, without any setting:
- Person known (Telegram, the Home Assistant app, voice recognition, or only one person at home): the history belongs to the person and follows them from room to room. You can start a sentence in the living room and go on in the kitchen.
- Nobody recognised: the history stays in the room. Two people in two rooms don't see each other's conversations.
- Private area: a room labelled as private in Home Assistant is a hard border. What starts there stays there, even for a known person, and nothing from outside comes in.
This is the history outside a thread. Inside one, the rules change, and that's where the first lesson comes from.
Threads: the concern is the unit
A thread is a concern that outlives a conversation. Examples: setting up an appointment, adding a new device, listening to the answering machine, cooking a recipe step by step, asking a research agent something that takes an hour.
Every thread has an owner, and the kind of thread decides which (a skill declares it with bound:):
| Owner | Who sees and continues it | Examples |
|---|---|---|
| person | only that person, on every satellite and in Telegram | a task, an appointment, a vocabulary test |
| room | anyone in that room | the answering machine, cooking, a quiz |
| house | anyone, wherever it's taken up | a device watch offer |
| chat | that Telegram chat | everything that starts in Telegram |
Then, for every new turn, Mira decides which thread it belongs to. The first rule that applies wins:
- 1. A direct answer to an announcement of the thread. Same device, within the follow-up window after Mira said something for that thread. Decided by code.
- 2. The same conversation. Home Assistant's
conversation_id(or the Telegram chat) is already linked to the thread. Decided by code. - 3. Waiting here. The model sees at most three waiting threads of this person and this room, newest first, and decides whether the user is continuing one, cancelling it or talking about something else. There are no fixed phrases. Decided by the model.
- 4. Otherwise the turn belongs to no thread.
The order matters. Where the code knows for sure, the model doesn't get to guess. The model only decides the genuinely ambiguous case: “Did ‘yes, Tuesday’ refer to the appointment from this morning?”
Some borders always hold. Nothing continues across channels. A private area sees only its own threads. And a person's thread is never shown to anyone else.
Lesson 1: a dialog that serves a thread belongs to the thread, not to whoever is speaking
Here's what happened on my test system on 16 November. One person at an Echo Show added a Matter motion sensor:
- 1. “I have a new Matter device.” Nobody recognised, so this ran in the conversation's history.
- 2. Mira asked which room it goes in. The answer, “the living room”, was recognised as Anna, so it ran in Anna's history. Mira proposed a name: “Motion sensor living room.”
- 3. “Yes, that’s fine.” This was the same Home Assistant conversation (same
conversation_id, visible in the pipeline debug), but recognised as Martin, so it ran in Martin's history, which was empty.
The model then called device_finish with the name “Motion sensor hallway”. That name appeared nowhere in its context. One dialog had run in three histories, and in the last one the model was on its own.
The obvious suspect is voice recognition. It was wrong twice, after all. But better recognition wouldn't fix the design. Even a perfect recogniser would split the dialog the moment a second person answers. That's normal in a household: one person starts adding the device, the other says “living room.”
The fix was to separate who speaks from which history the model sees:
- Every turn that belongs to a thread runs in the thread's history, whoever speaks. It no longer matters who is recognised for which dialog the model is in.
- A turn that starts a thread ran in the speaker's own history, because the thread didn't exist yet. When it's done, it is moved into the thread's history whole: user message, tool calls, results and answer, in one transaction. The conversation is linked to the thread, so the next sentence finds it by rule 2.
- The thread's history lives as long as the thread, not the voice conversation's five minutes.
- When the thread ends, Mira's code writes a summary into the own history of every participant: what the thread was, how it ended, its fields or plan, and Mira's last sentence. No model writes it. It's marked as a record, not as something said, so the model can refer to it (“what did you call it?”) without repeating it unprompted.
This split is easier to see from the prompt. Mira builds it in layers: the cached part (rules, house structure, tools), then the history, then the current turn. The current turn is rebuilt for every request: time, room, who is speaking, their personal profile, the memory facts that match the question, permissions, and the state of the thread. So the speaker still matters a lot. It just matters in the right place:
| Decided by the speaker, every turn | Decided by the thread |
|---|---|
| Whose profile and memory facts the model sees | Which earlier turns the model sees |
| What the turn is allowed to do | What's still missing, and what was proposed |
| The “speaking:” line | When the dialog ends |
If Martin finishes the dialog, the model sees Martin's memory and Martin's permissions, and the whole dialog that led here, including Anna's answer. One consequence I'll come back to: old turns stay in the history verbatim, including the profile lines and memory facts they carried at the time.
The cost: no extra model call. One indexed lookup per turn, a transaction of a handful of rows when a turn moves, one write per participant when a thread ends.
One rule I deliberately did not build: making Mira ask back when an answer refers to something missing from her context. It would have patched a broken history after the fact. With the thread's history, the history isn't broken.
Lesson 2: voice and chat need different rules
Three days later, the fix for voice broke Telegram.
On 19 November, in one Telegram chat:
- 1. “Remember for this conversation: my favourite number is 37.” This ran in the chat's history.
- 2. “I want to create an appointment.” This started a thread, so by Lesson 1 the turn moved into the thread's history, and the chat was linked to the thread.
- 3. “Which favourite number did I tell you earlier?” This ran in the thread's history. Mira: “You haven't told me a favourite number in this chat.”
Worse, when the thread ended, its turns were gone from the chat for good. And what Mira sent into the chat by herself (a reminder, a thread's result) wasn't in any history at all. So “what did you just send me?” had no answer.
The user sees the whole chat: every line, theirs and Mira's, including what Mira sent on her own. The model should see the same. The thread's history was built for a problem Telegram doesn't have. A chat isn't split between voices. Its person and its place are never in doubt, and it lives without a time limit.
So the rule for Telegram is different:
- A Telegram turn always runs in the chat's history, also inside a thread. The thread is still bound to the chat, the chat is still linked to it, and the thread's state is still in the prompt. Only the history doesn't switch.
- The summary is written anyway when the thread ends. It repeats what the dialog already shows, but it survives when the history is trimmed.
- What Mira sends by herself gets a delivery record in the chat's history.
This is the part I'd most want the person on X to take away. His setup is exactly this mix: long-lived chat threads plus voice. A single rule for both is wrong for one of them. Chat wants a stable history tied to the window. Voice wants a history tied to the concern, because the window doesn't exist.
Other agents attach to the thread, not to the session
Now the Hermes part. The question was really: if my voice assistant hands work to another agent, where does the answer go?
In Mira, a remote agent doesn't attach to a conversation or a session. It fills a thread, just like a user does. A skill describes the agent (its A2A address and a token). The skill's thread names a field or a plan that the agent fills:
- 1. “Ask Hermes which heat pump suits our house.” Mira starts the skill's thread and sends the question to Hermes over A2A. The A2A context belongs to the thread, not to the user's chat.
- 2. At a satellite, the turn waits up to 10 seconds for the agent. If the result comes in time, Mira says it in the same answer. Otherwise: “I've passed it on and will come back to you.”
- 3. Hermes asks back: “How big is the living area?” This becomes an agent request, a message to the thread's owner, at the satellite where they are or on their phone. “140 square metres” goes back to Hermes.
- 4. An hour later Hermes is done. The result is filled into the thread as if the user had said it, the thread finishes, and the owner gets the overview as a message of the thread.
- 5. “Forget it” ends the thread, and Mira tells Hermes it can stop.
There's no voice session talking to other sessions here. The voice side starts a thread. The agent works on the thread. The result is delivered to the thread's owner, wherever they are, not to the conversation it came from. That conversation has long timed out. Asynchronous runs are stored after every round and survive a restart of Mira, so “I'll come back to you” is a promise the system can keep.
A few things I learned about Hermes itself while building this, from its source and a test against v0.23.1 (it changes quickly, so check your version):
- Cancel: A cancel is answered with
canceled, but the agent's model turn runs to its end. The cost of that turn is spent anyway. - Turns: A context allows at most 5 back-and-forths (
A2A_MAX_PINGPONG_TURNS, up to 20). - Timeout: A reply times out after 300 seconds by default. A long research job needs
A2A_REPLY_TIMEOUTraised. - Asking back: Asking back works when the persona says when to ask: the answer starts with
[INPUT_REQUIRED], and Mira receivesinput-required.
What's still open
- A change of speaker inside a thread is ignored for now. Whoever continues the running dialog continues the thread, even a person's thread. That's deliberate, but it means someone else in the room can finish your appointment.
- What a shared history carries along. Because old turns are kept verbatim, a thread's history also holds the memory facts that were matched for earlier speakers. In a room thread, the next speaker's turn can see them. I haven't decided yet whether to strip them when the speaker changes.
- Group chats are one history, which fits, but the people writing in them aren't told apart yet.
- A turn that touches two threads moves into the last one it took up. I assume that's rare and log it.
- The full run at the Echo Show, the Matter dialog with two voices end to end, is still on my list. The parts are built and tested, the whole scene isn't yet.
If you're building something similar
- 1. Separate conversation, history and thread. They have three different lifetimes, and most session bugs come from tying them together.
- 2. Tie state to the concern and its owner, not to the channel or the session.
- 3. Let code assign where it knows; let the model decide only where it has to guess.
- 4. Deliver results to the owner, not to the sender. In voice, the sender is gone by the time the answer arrives.
- 5. Give chat and voice different rules on purpose. The fix for one broke the other in my house within three days.
Mira is open source: github.com/miraassist/mira. The specs these rules come from are in the repository under docs/spec, including the two bugs above, with dates.
¹ The original turns are in German; the names of devices too (the hallway sensor was “Bewegungsmelder Flur”). The specs in the repository quote them as spoken.
