Field ContextMessagePropertyKey
Set to true on the AdditionalProperties of the retrieved-context
ChatMessage this middleware injects, marking it pinned: a history reducer must
never evict it.
It exists because the injected block breaks the shape a turn-based reducer assumes. The
block is a second ChatRole.User message sitting immediately before the real user
message, so the tail of the list is user-then-user rather than the user/assistant pairs
EdgeChatTokenBudgetReducer evicts in - and evicting the grounding the whole recipe
exists to supply, to make room for history, would be the worst possible trade.
The literal is duplicated in Qavren.Edge.Chat.Onnx on purpose.
Qavren.Edge.Rag does not reference that package and must not, so the two cannot share
a constant; the chat package's ChatHistoryOptions.PinnedMessageKeys defaults to this
exact string and a tier-1 test asserts the two literals are equal. That is the same
deliberate duplication, with the same asserted-equality guard, that sub-project 2 already
uses for EdgeVectorData.QueryGeneratorServiceKey and
EdgeEmbeddings.QueryServiceKey. A reducer that does not know the key simply sees an
ordinary user message - it degrades to the old behaviour rather than breaking.
public const string ContextMessagePropertyKey = "qavren.edge.rag.context"
Returns
- string
- Set to true on the AdditionalProperties of the retrieved-context ChatMessage this middleware injects, marking it pinned: a history reducer must never evict it. It exists because the injected block breaks the shape a turn-based reducer assumes. The block is a second ChatRole.User message sitting immediately before the real user message, so the tail of the list is user-then-user rather than the user/assistant pairs EdgeChatTokenBudgetReducer evicts in - and evicting the grounding the whole recipe exists to supply, to make room for history, would be the worst possible trade. The literal is duplicated in Qavren.Edge.Chat.Onnx on purpose. Qavren.Edge.Rag does not reference that package and must not, so the two cannot share a constant; the chat package's ChatHistoryOptions.PinnedMessageKeys defaults to this exact string and a tier-1 test asserts the two literals are equal. That is the same deliberate duplication, with the same asserted-equality guard, that sub-project 2 already uses for EdgeVectorData.QueryGeneratorServiceKey and EdgeEmbeddings.QueryServiceKey. A reducer that does not know the key simply sees an ordinary user message - it degrades to the old behaviour rather than breaking.