Query Flow
July 31, 2026 · View on GitHub
This document traces how a natural-language query travels from a HiveMind satellite
through hivemind-core to the persona, and how the streamed answer returns to the
satellite.
Overview
satellite hivemind-core PersonaAgentProtocol
| | |
|---HiveMessage(QUERY)--->| |
| | policy check |
| |---natural_language_query(utt, lang)->|
| | | Persona.stream(...)
| |<--yield "sentence 1"-------------|
|<--HiveMessage(QUERY.RESPONSE, chunk="sentence 1")----------|
| |<--yield "sentence 2"-------------|
|<--HiveMessage(QUERY.RESPONSE, chunk="sentence 2")----------|
| |<--yield None (sentinel)----------|
|<--HiveMessage(hive.query.complete)-------------------------|
Step by step
-
Satellite sends a QUERY HiveMessage. The payload holds the utterance text and the language tag.
-
hivemind-corereceives the message. It runs the policy admission chain (ACL, blacklists, and so on) before it proceeds. -
hivemind-corecallsnatural_language_query(utterance, lang)on thePersonaAgentProtocolinstance. This is the contract thatAgentProtocoldefines inhivemind-plugin-manager. -
The plugin calls
Persona.stream(messages, lang=lang), wheremessagesis[{"role": "user", "content": utterance}]. The persona works through its configured solver chain until one solver produces output. -
The plugin forwards each non-empty chunk that
Persona.streamyields as aQUERY.RESPONSEHiveMessage back to the originating satellite. Chunks are typically sentence-length, so the satellite can speak them in order as they arrive. -
After the last chunk, the plugin yields
None.hivemind-corethen sendshive.query.completeto the satellite, to signal that no more chunks follow.
Error handling
If Persona.stream raises an exception, the plugin logs it and yields None
immediately. The satellite receives hive.query.complete with no answer chunks
before it. The satellite can treat that as an empty or failed response.
Streaming vs. full response
Because the plugin forwards chunks as they are produced, the latency to the first
spoken word depends on how quickly the first solver returns its first sentence, not
on the total generation time. This is the main reason for the streaming contract in
AgentProtocol.