Skip to content

The agent that grows with you

docs(moa): scope the byte-stable aggregator prefix claim to OpenAI-compatible wires

teknium1026551488f3a
diff --git a/agent/moa_loop.py b/agent/moa_loop.py
index d24371cc167..0742b888715 100644
--- a/agent/moa_loop.py
+++ b/agent/moa_loop.py
@@ -896,7 +896,10 @@ def _attach_reference_guidance(agg_messages: list[dict[str, Any]], guidance: str
tool loop ends on ``user(task)``, and a merged ``user(task + guidance)`` byte-differs
from the ``user(task)`` every later iteration replays, so the provider prefix cache
collapsed to the system prompt on iteration 2 of every turn (#112358). Converters
- that require strict alternation already merge adjacent same-role turns.
+ that require strict alternation (Anthropic Messages, Converse, native Gemini) merge
+ adjacent same-role turns, so there the task turn still varies on iteration 1; on the
+ OpenAI-compatible wire the request ends ``user(task), user(guidance)``, which a
+ chat template that enforces strict user/assistant alternation rejects.
"""
agg_messages.append({"role": "user", "content": guidance})
diff --git a/website/docs/user-guide/features/mixture-of-agents.md b/website/docs/user-guide/features/mixture-of-agents.md
index 5f197f2a1d2..25b73724a16 100644
--- a/website/docs/user-guide/features/mixture-of-agents.md
+++ b/website/docs/user-guide/features/mixture-of-agents.md
@@ -243,9 +243,9 @@ MoA is built so the **main conversation's prompt cache is never broken**. Select
Both internal call types cache normally:
- **Reference models** receive a trimmed, deterministic view of the conversation (system prompt and tool transcript stripped — see the loop above). Because that view is a stable function of the stable history, a reference model's prompt prefix repeats across iterations and caches normally. References are short advisory calls with no tools.
-- **The aggregator** is the acting model. The reference outputs are appended as their *own* trailing user message of private guidance — never merged into your message. Because that block sits at the tail — below the entire stable prefix (system prompt + your message + prior tool history) — it does not invalidate any cached prefix: every request in a tool loop is a byte-identical extension of the previous one minus its guidance block, so the aggregator gets a cache hit on everything above the injection and only the freshly appended tail is new. That is exactly how every normal turn behaves, where each new user message is also uncached tail tokens.
+- **The aggregator** is the acting model. The reference outputs are appended as their *own* trailing user message of private guidance — never merged into your message. Because that block sits at the tail — below the entire stable prefix (system prompt + your message + prior tool history) — it does not invalidate any cached prefix: on OpenAI-compatible aggregators every request in a tool loop is a byte-identical extension of the previous one minus its guidance block, so the aggregator gets a cache hit on everything above the injection and only the freshly appended tail is new. That is exactly how every normal turn behaves, where each new user message is also uncached tail tokens. (Aggregators on the Anthropic Messages, Bedrock Converse or native Gemini wire fold the guidance into your message on the first iteration of a turn — those converters merge adjacent user turns — so there the cache hit still starts above your message.)
-So MoA does not sacrifice prompt caching on either call type. Its only real cost is the extra reference calls per iteration — you pay for multiple model perspectives, not for broken caches. The long-lived conversation prefix shared with the rest of Hermes is fully intact.
+So MoA does not sacrifice prompt caching on either call type. Its only real cost is the extra reference calls (once per user turn with the default `fanout`) — you pay for multiple model perspectives, not for broken caches. The long-lived conversation prefix shared with the rest of Hermes is fully intact.
## Notes