Path: redb-route/redb.Route.Llm/LlmHeaders.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm/LlmHeaders.cs
----
namespace redb.Route.Llm;
///
/// Header keys used by the LLM connector. All keys are lowercase to match
/// existing transport conventions (Kafka, RabbitMQ, Http).
///
public static class LlmHeaders
{
/// Conversation identifier — links a message to a multi-turn dialog.
public const string ConversationId = "llm.conversation.id";
///
/// Marks the outbound message as a streaming response so transports
/// (HttpConsumer in redb.Route.Http, WebSocket) switch to
/// chunked / SSE / per-frame wire encoding instead of buffering the body.
/// Set by for stream=body; stream=calls returns the final text and
/// does not set it.
///
public const string Streaming = "llm.streaming";
/// System prompt override for a single call.
public const string SystemPrompt = "llm.system";
///
/// Fixed opening messages placed before the loaded conversation history on this call — the
/// value is an of , first one a
/// user turn. Rides into : sent on every
/// iteration, never persisted, survives a branch rebuild. Mark the last message with
/// to extend the cached prefix past the
/// system prompt.
///
public const string Preamble = "llm.preamble";
/// Logical role of the message: "user", "assistant", "system", "tool".
public const string Role = "llm.role";
/// Model identifier resolved from the connection factory.
public const string ModelId = "llm.model.id";
/// Provider identifier resolved from the connection factory ("anthropic", "openai", ...).
public const string ProviderId = "llm.provider.id";
/// Token usage written by the producer after a call (input).
public const string TokensIn = "llm.tokens.in";
/// Token usage written by the producer after a call (output).
public const string TokensOut = "llm.tokens.out";
///
/// Prompt tokens WRITTEN to the provider's cache on this exchange, billed at a premium over
/// normal input. Zero while is on usually
/// means the prefix is below the provider's length floor.
///
public const string CacheWriteTokens = "llm.tokens.cache.write";
///
/// Prompt tokens SERVED FROM the provider's cache on this exchange, billed at a fraction of
/// normal input.
///
/// This is the header that says caching works. Zero across repeated calls with an
/// unchanged prefix means something in that prefix is not byte-stable — and nothing else
/// reports it: is the uncached remainder, so a broken cache looks
/// exactly like an expensive prompt.
///
public const string CacheReadTokens = "llm.tokens.cache.read";
/// Estimated cost in USD written by the producer (optional).
public const string CostUsd = "llm.cost.usd";
// ── Transcription (stt://) ────────────────────────────────────────────────
///
/// ISO-639-1 language hint for stt://, overriding the endpoint option. Written
/// back after the call when the provider reports which language it heard.
///
public const string TranscriptionLanguage = "llm.transcription.language";
/// Per-exchange decoding hint for stt://, overriding the endpoint option.
public const string TranscriptionPrompt = "llm.transcription.prompt";
///
/// Name to upload the recording under, overriding the endpoint option. Decides which
/// demuxer the speech endpoint picks, so it is the difference between a decoded voice
/// note and a rejected upload.
///
public const string TranscriptionFileName = "llm.transcription.fileName";
/// Speech model that produced the transcription.
public const string TranscriptionModel = "llm.transcription.model";
/// Provider that produced the transcription.
public const string TranscriptionProvider = "llm.transcription.provider";
///
/// Number of characters recognised (int). Deliberately the length and not the
/// text: a header travels into logs and dead letters, and a transcription is the
/// speaker's own words. Zero says the recording held no speech.
///
public const string TranscriptionChars = "llm.transcription.chars";
///
/// Length of the recording in seconds (double), when the provider reports it —
/// the unit speech APIs bill in. Absent on providers that answer with the plain
/// {"text": ...} shape, which is most local servers; a caller that must have the
/// number should take it from the transport that delivered the audio.
///
public const string TranscriptionDuration = "llm.transcription.duration";
/// Stop reason returned by the provider: "end_turn", "tool_use", "max_tokens", "stop_sequence".
public const string StopReason = "llm.stop_reason";
/// Number of tool-loop iterations consumed by the agent for this exchange.
public const string ToolIterations = "llm.tool.iterations";
/// Name of the tool currently being executed (set on the child exchange forwarded by the bridge).
public const string ToolName = "llm.tool.name";
/// Target endpoint URI invoked by a .
public const string ToolBridgeEndpoint = "llm.tool.bridge.endpoint";
/// Tool-use identifier from the model — propagated to audit/idempotency stores.
public const string ToolUseId = "llm.tool.use_id";
/// Approval identifier when a tool call awaits or has received approval.
public const string ApprovalId = "llm.approval.id";
/// Async-batch identifier set by LlmCallbackProcessor when a webhook arrives.
public const string BatchId = "llm.batch.id";
/// Async-batch lifecycle status ("completed" / "failed" / "cancelled").
public const string BatchStatus = "llm.batch.status";
/// True when the callback was a duplicate (already-processed batch); routes can short-circuit on this.
public const string BatchDuplicate = "llm.batch.duplicate";
///
/// Conversation message id assigned by
/// when appends an assistant turn from a completed batch callback
/// (set only when the originating is true).
///
public const string ConversationMessageId = "llm.conversation.message.id";
///
/// Stable identifier of the principal that initiated this call. Read by
/// when the fluent builder declares
/// .User("${header.X-User-Id}") (or any literal expression) and
/// stamped on every persisted row of the run as
/// MessageProps.UserId / ConversationMessageMeta.UserId.
///
public const string UserId = "llm.user.id";
///
/// Header-name prefix for free-form audit tags. Any inbound exchange
/// header named llm.audit.<tag> is captured by
/// and stamped on every persisted row of the
/// run as MessageProps.AuditTags entry { Key=<tag>, Value=<header value> }.
/// Tags also accumulate from the fluent .Audit(k, v) builder; both
/// sources merge (header overrides builder).
///
public const string AuditTagPrefix = "llm.audit.";
}