| Internet-Draft | kvsig | December 2026 |
| Petrov | Expires 7 June 2027 | [Page] |
This document specifies stable identifiers for a chat conversation and its prefixes, derived from a stateless request to a large language model (LLM) chat API with no cooperation from the client. The same request content produces the same identifiers whichever API dialect carried it, in every component that holds the same deployment key, and the identifiers reveal no content to anyone without that key. It defines a dialect-independent canonical form for chat requests, an exact and a loose profile, keyed identifiers derived with HMAC-SHA-256, and test vectors.¶
This note is to be removed before publishing as an RFC.¶
The latest revision of this draft can be found at https://kvsig.org/spec/. Status information for this document may be found at https://datatracker.ietf.org/doc/draft-petrov-kvsig/.¶
Source for this draft and an issue tracker can be found at https://github.com/Podwarden/kvsig.¶
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."¶
This Internet-Draft will expire on 7 June 2027.¶
Copyright (c) 2026 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
Stable ids for a conversation and its prefixes, derived from a stateless request with no client cooperation; the same ids across API dialects and across components that share a deployment key; no content leaked to holders of ids. Non-goals: token-level KV block hashing, identity across deployments, stateful APIs.¶
This document specifies how to turn one stateless chat request into a set of identifiers. The request is canonicalised into a form that does not depend on the API dialect, encoded as restricted deterministic CBOR, and hashed with HMAC-SHA-256 under a key that belongs to one deployment. The ids are meant for components that share that key: a router that sends a conversation to the replica that holds its cache, a gateway that groups requests into conversations, a log that follows a session.¶
The ids are not a security boundary and not a session identifier. They identify content. Section 10 and Section 11 say what follows from that.¶
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.¶
Each term is defined once, here, and used in the same sense in the rest of the text.¶
The JSON document a client sends to a chat API, after parsing. Only the members that a dialect mapping reads (Section 4) matter. All other members (for example the model name or sampling parameters) are ignored.¶
One API request format with a mapping to the canonical form. This version
defines openai.chat, openai.responses and anthropic.messages
(Section 4).¶
A canonical map with a role, an optional name and a list of parts (Section 3.2).¶
One element of a message: text, media, a tool call, a tool result, reasoning, or an opaque value (Section 3.3).¶
The leading run of messages whose role is system or developer. The head
ends at the first message with another role.¶
The messages in the leading run are the head messages. Every later message is
a body message, including a later system or developer message.¶
A canonical map that describes one tool the model may call (Section 3.4). The tool list is the ordered list of all tool definitions of a request.¶
The triple of head messages, tool definitions and body messages that a dialect mapping produces from a request (Section 3). It does not depend on the dialect.¶
A text string that holds a JSON value in the one serialisation defined in Section 5.3. It carries tool arguments, tool schemas and unknown values.¶
The canonical form as it is, with nothing removed.¶
A named, versioned table of transformations that remove harness noise from
the canonical form (Section 6). The result is the loose form. This version
defines the profile loose/1.¶
A 17-byte value: the epoch byte followed by 16 bytes of HMAC output. It is written as 34 lowercase hexadecimal characters (Section 7.3).¶
A short ASCII string that names the kind of an id and keeps ids of different kinds apart (Section 7.2).¶
The id of one message on its own (msgs[i], loose_msgs[i]).¶
The id of the head messages and the tool list together (head,
loose_head). The sys id covers the head messages alone and the tools id
the tool list alone.¶
The id of a message together with everything before it (nodes[i],
loose_nodes[i]). A node id is chained from the head id and the message ids.¶
The id conv, derived from the loose head messages and the first body
message that has content in the loose form (Section 7.6). It exists only in
the loose form.¶
An id of one tool definition or one part of a head message (Section 7.9). This is a proposed extension.¶
A 32-byte secret shared by the components of one deployment, with an epoch (Section 8).¶
One byte that names a deployment key. It is the first byte of every id.¶
The current key plus older keys that are still accepted for lookups.¶
A byte string of at most 255 bytes that is mixed into every id, so that tenants that share a key still get different ids (Section 7.1).¶
The defined result for a request that cannot be given ids: it is not a chat request of the dialect, its canonical form is over the size cap, or it nests too deep (Section 5.4).¶
A request that continues history that is held by the server, so that its messages are not the whole conversation (Section 4.3).¶
The assistant message in a provider response, canonicalised alone, so that its id can be compared with the same message in the next request (Section 9.3).¶
Level 1, 2 or 3 (Section 9).¶
All structures in this section are CBOR maps, arrays and strings. They are written in CDDL ([RFC8610]) for precision. CDDL is informative here; the text is normative.¶
canonical-form = {
"head": [* message], ; head messages
"tools": [* tool], ; the tool list, in request order
"messages": [* message], ; body messages
}
¶
The map {"head", "tools", "messages"} is the form that the test vectors
carry as canonical_bytes_b64. Ids are not computed over it as a whole. They
are computed over parts of it (Section 7).¶
message = {
"role": tstr,
? "name": tstr, ; present only when the request gives a non-empty name
"parts": [* part],
}
¶
role is the role string of the request. A role that is missing or not a
string is the empty string.¶
name is kept only when the request gives a non-empty string.¶
A message that is not an object in the request becomes
{"role": "", "parts": [opaque]}: it is kept, never dropped (Section 3.3).¶
A message may have no parts.¶
Each part is a map. Its member t names its type.¶
``` part = text / media / tool-call / tool-result / reasoning / opaque¶
text = { "t": "text", "v": tstr } media = { "t": "media", "sha256": bstr .size 32, "mime": tstr, "src": "bytes" / "url" / "file_id" } tool-call = { "t": "tool_call", "name": tstr, ("args": tstr // "args_raw": tstr), "ref": int } tool-result = { "t": "tool_result", "ref": int, ? "error": true, "parts": [* part] } reasoning = { "t": "reasoning", "v": tstr } opaque = { "t": "opaque", "type": tstr, "sha256": bstr .size 32 } ```¶
textText. An empty text is not a part: it is dropped. Adjacent texts are not merged. A string content of a message is one text part.¶
mediaA reference to binary content. sha256 is the SHA-256 ([RFC6234]) of the
content, as 32 raw bytes. src says what was hashed, so that the three
sources can never collide: bytes (the decoded bytes of inline data), url
(the UTF-8 bytes of a URL), or file_id (the UTF-8 bytes of a provider file
id). mime is the media type, lowercase, with surrounding ASCII whitespace
removed. It is taken only from a data-URL header or an explicit field of the
request. It is never guessed from a file extension, and it is the empty
string for a URL or file id. Media bytes are never put into the canonical
form.¶
tool_callA call to a tool. name is the tool name. args is the canonical JSON text
(Section 5.3) of the arguments, when the arguments parse as JSON.
args_raw is the arguments string as given, when it does not parse as JSON.
The two members are never both present, so a raw string can never equal
valid JSON. ref is the position of the call in its assistant message
(Section 3.5).¶
tool_resultThe result of a tool call, as the content of a message with role tool.
ref is the position, in the preceding assistant message, of the call that
the result answers, or -1 when no call is found (Section 3.5). error is
present, with the value true, only when the request marks the result as an
error. parts holds the content of the result. It comes from the same
content mapping as the content of a message and so holds text, media and
opaque parts.¶
reasoningReasoning text that the model produced. It occurs in assistant messages. In
openai.chat it is the first part. In the other dialects it is at its
position in the turn.¶
opaqueA value that the dialect mapping does not understand. type is the type
member of the value when it is a string, otherwise a name that the mapping
gives (or the empty string). sha256 is the SHA-256 of the UTF-8 bytes of
the canonical JSON text of the value, with the value's own top-level
cache_control member removed (see below). An opaque value is never dropped.¶
The cache_control rule: a member named cache_control at the top level of an
opaque value, and of an Anthropic tool definition that is not a custom tool, is
removed before hashing. A cache marker changes where a provider caches, not
what the conversation is. A member of that name deeper inside a value is data
and is kept.¶
tool = function-tool / other-tool
function-tool = { "name": tstr, "desc": tstr, "schema": tstr }
other-tool = { "type": tstr, "def": tstr }
¶
A function tool has a name, a description (the empty string when absent) and
the canonical JSON text of its parameter schema. When a function tool has no
schema, the canonical JSON text is null. Any other tool (a server-side tool,
a tool of a kind the mapping does not know) is {"type", "def"}, where type
is the type member when it is a string, otherwise the empty string, and
def is the canonical JSON text of the whole definition.¶
Open issue (decision 0002, open question 3): A tool without a schema gets
the schema text null, in every dialect. OpenAI may omit parameters, and
Anthropic always sends a schema. Whether an absent schema and a schema null
should differ is not decided. The component vector tool-no-parameters pins
the current behaviour.¶
The order of the tool list is the order of the request. Tool definitions are never sorted in the exact profile.¶
Tool-call ids never enter a hash. A call and its result are linked by a position, so that a message has the same canonical form alone and inside a later request.¶
The ref of a call is its zero-based index in its own assistant message.
What is counted is defined by each dialect (Section 4).¶
The ref of a result is the index of its call in the nearest preceding
assistant message that holds a call with the same id. When no such call
exists (the result comes first, the id is unknown, or the dialect cannot name
a call), the ref is -1.¶
When one assistant message holds several calls with the same id, a result takes the index of the last of them.¶
An implementation holds a map from call id to index while it reads the messages in order. An assistant message updates the map as it is read, and the map is never cleared. A result looks up its id in the map as it is at that point.¶
The head is the leading run of messages with role system or developer,
after the dialect mapping has produced its messages and put any top-level
system prompt first. A message that follows the first message of another role
is a body message even if its role is system or developer. So an
instruction that is injected in the middle of a conversation extends the body.
It does not change the head, and prefix ids stay prefixes.¶
A dialect mapping turns a request into the canonical form. All mappings aim at cross-dialect equivalence: one conversation sent through two dialects gives one canonical form, and so the same ids, unless Section 4.6 lists the conversation as a known non-equivalence.¶
An implementation reads only the request members named in this section. All other members are ignored.¶
Parsing. The request is parsed as a JSON text ([RFC8259]). Two inputs are
not repaired by the parser: a lone surrogate escape (for example \ud800) and
an object with a repeated member name. An implementation MUST keep a lone
surrogate until the Unicode rule of Section 5.2 is applied. For a repeated
member name the last value wins, at the position of the first occurrence. Member
order is kept where it matters (Section 5.3). A JSON library whose objects
reorder members (for example integer-like keys in JavaScript) is not suitable
for this step.¶
Not a chat request. The mapping returns the no-ids outcome when the request
is not an object, or when the member that holds the messages is missing or has
the wrong type. The member is messages for openai.chat and
anthropic.messages, and input (a string or an array) for openai.responses.¶
Text. A string content becomes one text part. An empty text is dropped.¶
Names and roles. A role or name that is not a string is the empty string. A name is kept only when it is a non-empty string.¶
Media from a URL string. A string that starts with data: and has a comma
is a data URL. The text between data: and the first comma is the header. It
is split at ;. The first item is the media type. The data is base64 when a
later item, stripped of surrounding whitespace and lowercased, is base64.
Otherwise the data is percent-decoded ([RFC3986], [RFC2397]); a % that does
not start a valid escape stays as it is. If the data decodes, the part is
media with src bytes, the hash of the decoded bytes and the media type
of the header. If it does not decode (invalid base64, or a lone surrogate in
the data), the whole URL string is treated as a plain URL. Any other string
(including a non-string, which counts as the empty string) is a plain URL: a
media part with src url, an empty mime, and the hash of the UTF-8 bytes
of the string.¶
Inline base64. Base64 data ([RFC4648], standard alphabet, with padding) is decoded after removing every ASCII whitespace character (space, tab, line feed, carriage return, form feed, vertical tab), in every dialect, so that line-wrapped data hashes the same as unwrapped data. Any other deviation (a character outside the alphabet, missing or wrong padding) is an error, and the value becomes an opaque part, except where stated otherwise above.¶
Tool arguments. An arguments string is parsed as a JSON text. The literals
NaN, Infinity and -Infinity are not JSON and do not parse. When parsing
succeeds, the part has args, the canonical JSON text of the parsed value.
When it fails, the part has args_raw, the string as given (including the
empty string). Arguments that the request gives as a JSON value other than a
string are used as that value: args holds its canonical JSON text. The
canonical JSON text of an absent value is null.¶
Opaque values. Any content that a mapping does not list is an opaque part.
This includes a content item or message that is not an object, an object whose
type is unknown, and a value that fails to decode. The names that the mappings
give as type when the value has none of its own are: content, part,
message, block, item, tool_call, function_call, refusal, audio,
instructions, reasoning.¶
Cache markers and citations. A cache_control member is ignored as
described in Section 3.3.¶
openai.chat)
Read messages (an array) and tools (an array). When tools is not an
array, read functions (an array) instead, and treat each entry f as
{"type": "function", "function": f}. When neither is an array, the tool list
is empty.¶
Tools. A tool object with type equal to function and a function
object becomes {"name", "desc", "schema"} from function.name,
function.description and function.parameters. Any other tool becomes
{"type", "def"} with def the canonical JSON text of the whole tool.¶
Messages. The role and name are read as in the common rules. The parts depend on the role.¶
Role tool, or the deprecated role function: the message has one part, a
tool_result with parts from the content. For role tool, ref comes
from tool_call_id (Section 3.5). For role function, ref is -1. The
name of a function message is kept as the message name. No other member of
such a message is read.¶
Any other role: the parts are, in this order,¶
For role assistant only: one reasoning part from the first non-empty
string among reasoning_content and reasoning (in that order).¶
The parts of content.¶
For role assistant only: when refusal is present and not null, an
opaque part of the value {"refusal": <value>}, with type name refusal.¶
For role assistant only: when audio is present and not null, an opaque
part of the value, with type name audio.¶
For role assistant only: one part per entry of tool_calls, in order.¶
For role assistant only: when function_call is present and not null,
one part for it, after the tool_calls parts.¶
Content. content may be null (no parts), a string (one text part), or an
array. Any other value is one opaque part with type name content. Each item
of an array is mapped as follows.¶
| Item | Part |
|---|---|
| a string | text |
| not an object | opaque, type name part
|
type is text, input_text or output_text; or there is no type and text is a string |
text from text (a non-string text is empty and dropped) |
type is image_url or video_url
|
media from the URL string, which is the url member of the image_url (or video_url) object, or the value itself when it is not an object |
type is input_audio, the member is an object |
media of the decoded data, src bytes, mime audio/ followed by format when format is a non-empty string, otherwise the empty string; opaque (the whole item) when data does not decode |
type is file
|
see below |
type is input_image
|
media from image_url when it is a non-empty string; else a file_id reference from file_id when that is a non-empty string; else opaque |
| anything else | opaque (the whole item) |
For a file item, let f be its file member. When f is an object and
f.file_data is a non-empty string: if it starts with data: it is a data URL
(see above); otherwise it is base64 data of unknown type (mime empty), and
opaque when it does not decode. Otherwise, when f.file_id is a non-empty
string, it is a file_id reference. Otherwise the item is opaque.¶
Tool calls. For the entry at index i of tool_calls:¶
Not an object: opaque with type name tool_call.¶
It has a function object: a tool_call with name from function.name
and the arguments from function.arguments (common rules).¶
Else it has a custom object: a tool_call with name from custom.name
and args_raw from custom.input (the empty string when not a string).¶
Otherwise: opaque with type name tool_call.¶
The ref is i. Every entry takes an index, including an entry that is not
an object. When the entry is an object with a string id, the map of
Section 3.5 gets id mapped to i. The legacy function_call, when it is an
object, is a tool_call with ref equal to the number of tool_calls entries
and no id; when it is not an object it is opaque with type name
function_call.¶
Head. The leading run of messages with role system or developer is the
head. Messages are mapped in order; the first message of another role starts
the body.¶
openai.responses)
Read input, instructions, tools, previous_response_id and
conversation.¶
Items. A string input is one item, a message with role user and that
content. An array input is the list of items. Any other input gives the
no-ids outcome.¶
Instructions. A non-empty string instructions is the first head message:
role system, one text part. An empty string gives no message. A value that is
neither a string nor null is a head message with role system and one opaque
part with type name instructions. Items follow instructions in the head
when they are a leading run of system or developer messages.¶
Assistant-side items. An item is assistant-side when it is an object and
its type is reasoning, function_call or custom_tool_call; or one of the
server-side tool types web_search_call, file_search_call, computer_call,
code_interpreter_call, image_generation_call, local_shell_call,
mcp_call, mcp_list_tools, mcp_approval_request; or it is a message
(type is message or absent) with role assistant.¶
A run of consecutive assistant-side items is one assistant message, in item
order. Any item that is not assistant-side (including an item that is not an
object) ends the run. The call counter for ref starts at 0 in each new
assistant message.¶
Items, one by one.¶
| Item | Result |
|---|---|
| not an object | a message with role "" and one opaque part, type name item
|
reasoning
|
one reasoning part (below); nothing, and no message is opened, when it has no text |
function_call
|
a tool_call with name and the arguments from arguments (common rules); its ref is the call counter, which then increases by one |
custom_tool_call
|
a tool_call with name and args_raw from input (the empty string when not a string); ref and counter as above |
| a server-side tool type | one opaque part (the whole item) |
assistant message
|
the parts of its content, appended to the assistant message |
function_call_output, custom_tool_call_output
|
a message with role tool and one tool_result with parts from output (content rules below) and ref from call_id
|
message, or no type
|
a message with the item's role (the empty string if not a string) and the parts of its content
|
anything else (item_reference and so on) |
a message with role "" and one opaque part (the whole item) |
For a function_call or custom_tool_call whose call_id is a string, the
map of Section 3.5 gets call_id mapped to the call's ref.¶
Reasoning. The candidate texts are the string text members of the items
of type reasoning_text in the content array. When there is no such item,
they are those of the items of type summary_text in the summary array. The
value is the non-empty candidates joined by a blank line (\n\n). When the result is non-empty, it is the value of
a reasoning part. When it is empty and encrypted_content is present and
truthy, the part is opaque with type name reasoning and the value
{"encrypted_content": <value>}. Otherwise there is no part.¶
Content. A string is one text part (none when empty). null is no parts.
Any other non-array is one opaque part, type name content. Each item of an
array:¶
| Item | Part |
|---|---|
| a string | text |
| not an object | opaque, type name part
|
type is input_text, output_text or text
|
text from text
|
type is input_image
|
as for openai.chat input_image
|
type is input_file
|
media from file_data (as file_data in openai.chat: a data URL, or base64 of unknown type; opaque when it does not decode), else a file_id reference from file_id, else a url reference from file_url (each when a non-empty string), else opaque |
type is refusal
|
opaque, type name refusal, value {"refusal": <value of refusal>}
|
| anything else | opaque (the whole item) |
Tools. A tool object with type equal to function becomes
{"name", "desc", "schema"} from name, description and parameters. The
strict member is ignored. Any other tool is {"type", "def"}.¶
Head. The messages that the items produce are put in order. The leading run
with role system or developer is added to the head after any
instructions message. The rest is the body.¶
Stateful requests. When previous_response_id or conversation is present
and not null, false, zero, an empty string, an empty array or an empty object,
the request is stateful. Its body is not the whole conversation. A stateful
request gets message, head, sys and tools ids (and their loose forms and
component ids), but its nodes and loose_nodes are empty lists and it has
no conv (Section 7.7).¶
anthropic.messages)
Read system, messages and tools.¶
System. When system is null, the empty string or the empty array, there
is no system message. Otherwise there is one head message with role system
and the parts of system, mapped as content (below): a string is one text
part, and an array has one part per block. So a system prompt sent as a string
equals the same text sent as one text block.¶
Messages. The messages are mapped in order; the head is the leading run of
messages with role system or developer after the top-level system.¶
A message with role assistant is one assistant message (below). Any other
message is a user turn, split as follows. When content is not an array, the
turn is one message with that role and the parts of the content. When
content is an array, each tool_result block is its own message, in place,
with role tool and one tool_result part. All other blocks, in order, form
messages with the turn's role: a run of other blocks between two tool results
is one message. A run is a message even when all its blocks are dropped (an
empty text), so it can have no parts. An empty array gives one message with no
parts.¶
Tool result. ref comes from tool_use_id (Section 3.5). parts come
from content (a string or an array of blocks), with images and documents
mapped as in a user turn, in place. error is present when is_error is the
JSON value true.¶
User and tool-result blocks. Content that is null is no parts, a string
is one text part (none when empty), an array is mapped block by block, and
any other value is one opaque part with type name content. In an array a
string is text. A block that is not an
object is opaque with type name block. text is text. image and
document are media (below), except that a document with a title or
context member is opaque. Every other block (including a nested
tool_result) is opaque.¶
Sources. An image or document block has a source object. When
source is not an object, the block is opaque. Otherwise:¶
type base64: media of the decoded data, src bytes, mime from
media_type; opaque when data does not decode.¶
type text with a string data: media of the UTF-8 bytes of data,
src bytes, mime from media_type.¶
type url with a string url: a url reference.¶
type file with a string file_id: a file_id reference.¶
otherwise: opaque (the whole block).¶
Open issue: For type text, the reference implementations encode data
to UTF-8 with lone surrogates kept as three-byte sequences (Python
surrogatepass), not replaced by U+FFFD as the rule of Section 5.2 says for
every other text. The vectors do not pin this. A request with a lone surrogate
in such a source is an edge case; the text is as implemented.¶
Assistant message. When content is not an array, the parts are those of
the content as above. Otherwise each block, in order:¶
| Block | Part |
|---|---|
| not an object | opaque, type name block
|
thinking
|
reasoning with the thinking string, when it is a non-empty string; otherwise nothing. The signature is not read. |
text
|
text |
tool_use
|
tool_call with name, args the canonical JSON text of input, and ref the index among the tool_use blocks of this message. When id is a string, the map of Section 3.5 gets id mapped to that index. |
anything else (redacted_thinking, server_tool_use, *_tool_result, any newer block) |
opaque (the whole block) |
Tools. A tool object with no type (or type custom) and a string
name becomes {"name", "desc", "schema"} from name, description and
input_schema. Any other tool becomes {"type", "def"}, with def the
canonical JSON text of the tool with its top-level cache_control removed.¶
Ignored. cache_control on any block is ignored, and citations are not
read.¶
The dialect name openai.completions is reserved. This version defines no
mapping for it. An implementation MUST NOT claim it.¶
One conversation sent through openai.chat, openai.responses and
anthropic.messages gives one canonical form, and so one set of ids, when it
uses a system prompt, tools, images, reasoning, a tool call and its result. The
vectors pin this (equivalent_to, Section 13).¶
These conversations do not map to the same canonical form, on purpose or because one dialect cannot express them:¶
A tool result marked as an error (Anthropic is_error). Chat and Responses
have no such flag.¶
Several reasoning blocks in one assistant turn (Anthropic interleaved thinking). Chat has one reasoning string.¶
Two assistant message items in a row in Responses become one message. Two Chat assistant messages stay two.¶
Responses reasoning that is given only as a summary. Chat carries the raw text.¶
Server-side tools of each provider, which have no counterpart elsewhere.¶
A Chat assistant refusal is placed after the content. A Responses
refusal part keeps its position.¶
The role of a head message. A system prompt sent as system and the same
text sent as developer differ in the exact profile, and in loose/1
(Section 6.4).¶
The bytes that ids are computed over are CBOR ([RFC8949]), restricted as follows.¶
Allowed types: unsigned and negative integers (major types 0 and 1), byte
strings (2), text strings (3), arrays (4), maps (5), and the simple values
false and true. Floats, tags, null, undefined, other simple values
and indefinite lengths MUST NOT occur.¶
Every integer and every length MUST be in its shortest form (preferred serialisation, [RFC8949] Section 4.2.1).¶
A map has text-string keys only, with no duplicate. Entries are sorted by the bytewise lexicographic order of each key's encoding ([RFC8949] Section 4.2.1). Because the encoding starts with the length, shorter keys sort first, and keys of equal length sort bytewise.¶
A text string is valid UTF-8 (Section 5.2).¶
In the canonical form integers occur only as ref. Byte strings occur as
sha256 and in the scope (Section 7.1).¶
Key order of the maps that occur, derived from rule 3:¶
| Map | Keys, in encoded order |
|---|---|
| canonical form |
head, tools, messages
|
| head payload |
head, tools
|
| message |
name (if present), role, parts
|
text, reasoning
|
t, v
|
media
|
t, src, mime, sha256
|
tool_call with args
|
t, ref, args, name
|
tool_call with args_raw
|
t, ref, name, args_raw
|
tool_result
|
t, ref, error (if present), parts
|
opaque
|
t, type, sha256
|
| function tool |
desc, name, schema
|
| other tool |
def, type
|
| scope |
tenant, cache_salt
|
An implementation MAY use any CBOR library whose output for this subset equals these rules. The reference implementation encodes the subset directly.¶
Before a string is encoded, lone UTF-16 surrogates are repaired. A well-formed surrogate pair is the single code point it stands for. A lone surrogate becomes U+FFFD. No Unicode normalisation is applied: strings that differ only by normal form are different.¶
This applies to every text string that is put in a CBOR text string, to every string and member name that is put in a canonical JSON text, and to every string that is hashed (URLs, file ids, canonical JSON text of opaque values).¶
Tool arguments, tool schemas, tool definitions and opaque values are JSON values. They are not mapped into CBOR. They are carried as a text string that holds their canonical JSON text, which is produced as follows. This keeps floats out of CBOR and keeps the member order of the client in the exact profile.¶
No whitespace. The separators are , and :.¶
Object members keep the order they had in the input in the exact profile. In the loose profile they are sorted by Unicode code point of the key (Section 6.2).¶
A repeated member name keeps its last value at the position of the first occurrence.¶
Strings are enclosed in ". Only ", \ and the control characters
U+0000 to U+001F are escaped. \b, \f, \n, \r and \t use these short
forms. The other controls use \u00xx with lowercase hexadecimal digits.
Every other character, including U+007F and non-ASCII characters, is literal
UTF-8.¶
Object keys are taken as Unicode scalars (lone surrogates become U+FFFD) before anything else. Keys that become equal are merged by the rule for repeated member names.¶
Numbers: the value is converted to the nearest IEEE 754 double (ties to
even). It is printed with the ECMAScript Number.prototype.toString
algorithm, as in [RFC8785] Section 3.2.2.3: zero and negative zero print as
0; with k shortest round-trip digits and exponent n (value =
0.digits x 10^n), the output is the digits followed by n - k zeros when
k <= n <= 21; the digits with a decimal point after n digits when
0 < n <= 21; 0. followed by -n zeros and the digits when -6 < n <= 0;
otherwise the exponent form (d, optionally .ddd, then e, a sign and the
decimal exponent, for example 1e+21, 1.5e-7). A number too large for a
double, and NaN or an infinity, print as null.¶
true, false and null are literals.¶
Depth counts arrays and objects only. Up to 128 nested containers are
allowed. A 129th makes the request get the no-ids outcome (Section 5.4).
Scalars never count. The depth of a value is counted from that value: the
arguments of a call, the schema of a tool, the whole tool for def, the whole
value of an opaque part.¶
The size of a canonical form is the length in bytes of the CBOR of the head
payload ({"head": ..., "tools": ...}) plus the length of the CBOR of each
body message (exact profile). The default cap is 2 MiB (2097152 bytes). A
request over the cap, a request that nests deeper than Section 5.3 allows, and
a request that is not a chat request of its dialect (Section 4) get the no-ids
outcome: an implementation MUST return no ids for them, and MUST NOT fail the
request. A request exactly at the cap gets ids.¶
An implementation MAY stop early on any lower bound of the size. For example it may count the code points of strings that appear verbatim in the canonical form, since each is at least as many UTF-8 bytes. It MUST NOT reject a request that the exact check accepts.¶
The cap is configurable per call. A different cap is local policy: it decides only whether ids exist, never what they are.¶
The cap bounds the canonical form, in which media is a 32-byte hash. It does not bound the size of media data in the request (Section 11.5).¶
loose/1
The loose profile is the canonical form without harness noise. A harness (a coding agent, for example) often changes the text of a request from turn to turn in ways that do not change the conversation: a reminder block, a date line, spacing, reasoning, or the member order in tool arguments. Loose ids ignore these. Exact ids do not.¶
The loose form of a canonical form is computed message by message and tool by tool. It is the canonical form with the transformations of this section applied. The profile is data: the table below. Any change to the table is a new profile name, and the profile name is part of every loose label (Section 7.2), so ids from two profiles are never equal by accident.¶
name: loose/1
block tags: ("<system-reminder>", "</system-reminder>"),
("<environment_context>", "</environment_context>")
whitespace: U+0009 U+000A U+000B U+000C U+000D U+001C U+001D U+001E U+001F
U+0020 U+0085 U+00A0 U+1680 U+2000..U+200A U+2028 U+2029
U+202F U+205F U+3000
role map: (empty)
¶
The whitespace set is the Unicode White_Space property plus U+001C to
U+001F.¶
Parts of a message are processed in order. Messages keep their role and name. A message that has no parts afterwards is kept, with an empty list of parts.¶
A reasoning part is removed.¶
A text part: its text is replaced by the result of the text rules below.
When the result is empty, the part is removed.¶
A tool_result part: its parts are processed by these same rules. The
part is kept, with ref and error unchanged, even when its parts are
empty.¶
A tool_call part with args: the canonical JSON text is parsed, and
written again as canonical JSON text with the members of every object, at
every depth, sorted by the code point of the key. A tool_call with
args_raw is unchanged.¶
media and opaque parts are unchanged.¶
Tool definitions: schema (function tool) or def (other tool) is rewritten
as in rule 4. Names, descriptions and types are unchanged. The tool list keeps
its order. The loose head payload is {"head": [loose head messages], "tools":
[loose tools]}.¶
Text rules. In this order:¶
For each block tag pair, in table order: remove every block from an opening tag to the next closing tag. Tags are matched with ASCII case-insensitivity (only A to Z fold to a to z). The search for the closing tag starts after the opening tag. Blocks do not nest: the first closing tag after an opening tag ends the block. Nothing is put in place of a removed block. An opening tag with no closing tag after it is not removed, and neither is the rest of the text.¶
Remove every line that holds only an ISO 8601 date or date-time, as defined by the pattern below. Lines end at U+000A only. The line terminator stays. The removed text is the whole line.¶
Replace every run of one or more whitespace characters of the table by one U+0020, and remove leading and trailing whitespace.¶
The line pattern, as a regular expression with ASCII digits only ([ \t] is
a space or a tab, \. a literal dot):¶
^[ \t]*[0-9]{4}-[0-9]{2}-[0-9]{2}(?:[T ][0-9]{2}:[0-9]{2}(?::[0-9]{2}(?:\.[0-9]+)?)?(?:Z|[+-][0-9]{2}:?[0-9]{2})?)?[ \t]*$
¶
with ^ and $ matching at the start and end of each line (lines end at LF
only; a CR is not part of the line terminator and stops a match). The pattern
does not check ranges: 9999-99-99 matches. A date inside a sentence does not
match and stays.¶
Open issue (decision 0002, open question 2): A date inside a sentence (for
example "Today's date is 2026-12-04") survives loose/1 and changes the
conversation id daily. The vector loose-date-in-sentence-kept pins the
current behaviour.¶
It does not rename roles. It does not remove name. It does not change
media or opaque parts, so an opaque value with different member order has
a different loose id. It has no harness-specific preamble rules.¶
Under loose/1 the role of a message is part of its identity. A client that
moves the same system prompt from system (or Responses instructions) to a
developer message gets a new sys and a new conv. Its exact ids change too.¶
loose/2 (not normative)
This subsection is informative. loose/2 is proposed by decision 0005. It is
experimental: it has no vector set, its ids may change until the decision is
accepted, and an implementation MAY omit it.¶
loose/2 is loose/1 plus one rule: a message whose role is developer has
role system in the loose form. The rule applies to head and body messages.
The block tags and the whitespace set are those of loose/1. In every loose
label the profile name is loose/2 (Section 7.2), so every loose id of every
request differs from its loose/1 id. Exact ids do not depend on the loose
profile. A deployment that changes the profile changes every conversation id
once. The reference library keeps loose/1 as the default profile.¶
H(K, label, scope, payload) =
epoch || HMAC-SHA-256(K.secret,
"kvsig/1" 0x00 label 0x00 u8(len(scope)) scope payload)[0:16]
¶
K.secret is the 32-byte deployment key and epoch is its one-byte epoch
(Section 8). HMAC is [RFC2104] and SHA-256 is [RFC6234].¶
"kvsig/1" is the spec label: the 7 ASCII bytes 6b 76 73 69 67 2f 31.
It separates ids of different spec versions.¶
0x00 is a single zero byte. label is the ASCII label of the id kind
(below). It MUST NOT contain a zero byte.¶
u8(len(scope)) is the length of the scope as one byte. A scope MUST NOT be
longer than 255 bytes.¶
scope is the scope bytes, which may be empty.¶
payload is the CBOR encoding (Section 5.1) of the payload map of the id
kind (below), or the concatenation of raw ids where stated.¶
The epoch is not an input to the HMAC. It is put in front of the 16 bytes that remain after truncating the 32-byte HMAC output to its first 16 bytes.¶
The scope is empty, or 32 bytes: the SHA-256 of the CBOR encoding of the map
{"tenant": <bstr>, "cache_salt": <tstr>} with a member left out when the
corresponding input is absent or empty. The inputs are a cache salt (a string)
and a tenant (bytes). How a deployment obtains them is outside this
specification. The id function accepts any scope of at most 255 bytes;
interoperability is defined only for the scope derivation above.¶
The label of an id kind is the kind name for exact ids. For loose ids it is the
profile name, a colon, and the kind name, for example loose/1:head.¶
| Kind | Exact label | Loose label (loose/1) |
|---|---|---|
| head |
head
|
loose/1:head
|
| head messages only |
sys
|
loose/1:sys
|
| tool list only |
tools
|
loose/1:tools
|
| message |
msg
|
loose/1:msg
|
| node |
node
|
loose/1:node
|
| conversation | none |
loose/1:conv
|
| tool (extension, Section 7.9) |
tool
|
loose/1:tool
|
| part (extension, Section 7.9) |
part
|
loose/1:part
|
A profile name MUST NOT contain a colon or a zero byte, and MUST NOT be empty.¶
An id is 17 bytes: the epoch byte, then 16 bytes of MAC. It is rendered as 34 lowercase hexadecimal characters. A reader gets the epoch from the first two characters. Where ids are concatenated into a payload (node and conversation ids), the raw 17 bytes are used, not the hexadecimal text.¶
Let H be the list of head messages, T the list of tool definitions, and
M[0], M[1], ... the body messages, all of the canonical form (exact
profile).¶
| Output | Label | Payload |
|---|---|---|
head
|
head
|
CBOR of {"head": H, "tools": T}
|
sys
|
sys
|
CBOR of {"head": H}
|
tools
|
tools
|
CBOR of {"tools": T}
|
msgs[i]
|
msg
|
CBOR of M[i]
|
nodes[i]
|
node
|
nodes[i-1] followed by msgs[i] (34 bytes), with nodes[-1] = head
|
tools is one order-sensitive id of the whole list: the same tools in another
order give another tools id. An empty tool list is the payload
{"tools": []}; it has an id like any other. The node ids chain: nodes[i]
fixes the head and every message up to i.¶
Let H', T' and M'[i] be the loose head messages, loose tools and loose
body messages (Section 6), and L the label prefix loose/1:.¶
| Output | Label | Payload |
|---|---|---|
loose_head
|
Lhead |
CBOR of {"head": H', "tools": T'}
|
loose_sys
|
Lsys |
CBOR of {"head": H'}
|
loose_tools
|
Ltools |
CBOR of {"tools": T'}
|
loose_msgs[i]
|
Lmsg |
CBOR of M'[i]
|
loose_nodes[i]
|
Lnode |
loose_nodes[i-1] followed by loose_msgs[i], with loose_nodes[-1] = loose_head
|
The loose node ids are chained over the loose message ids. They are not derived from the exact node ids.¶
Let a be the index of the first body message whose loose form has at least
one part. Then¶
conv = H(K, "loose/1:conv", scope, loose_sys || loose_msgs[a])
¶
with the raw 17-byte ids concatenated (34 bytes). When no body message has a part in the loose form, there is no conversation id.¶
A constant opener that loosens to nothing (an environment block, a reminder) would otherwise give every session the same id. It is skipped.¶
The tools are not in loose_sys, so adding or removing a tool in the middle
of a session (an MCP server, a deferred tool) does not start a new
conversation. The tools stay in the head and node ids: a different tool list
is a different prompt.¶
There is no exact conversation id. The conversation id identifies content, not a session: two users who open with the same message under the same head share it, unless a scope separates them.¶
For a stateful request (Section 4.3), nodes and loose_nodes are empty and
there is no conv. All other ids are computed as usual.¶
For a request that gets ids, an implementation produces:¶
epoch
head, sys, tools
msgs[], nodes[]
loose_head, loose_sys, loose_tools
loose_msgs[], loose_nodes[]
conv ; may be absent
¶
The lists have one element per body message, in order. Implementations MAY cache ids and loose forms, for example by message id. A cache MUST NOT change any id.¶
This subsection is a proposed extension (decision 0006), pinned by the
separate vector set vectors/v1-components and not by vectors/v1. An
implementation is conformant without it (Section 9.4). The ids of Sections 7.1
to 7.7 do not change when it is present.¶
For each tool definition and each part of each head message there is an id.
They use the same function H, key, epoch and scope.¶
| Output | Label | Payload |
|---|---|---|
tool_ids[i]
|
tool
|
CBOR of {"tool": T[i]}
|
loose_tool_ids[i]
|
loose/1:tool
|
CBOR of {"tool": T'[i]}
|
sys_parts[m][j]
|
part
|
CBOR of the head message H[m] with its parts replaced by the one-element list holding H[m].parts[j]
|
loose_sys_parts[m][j]
|
loose/1:part
|
the same, for the loose head message H'[m]
|
The reduced message keeps role, and name when present.¶
sys_parts has one list per head message, in order, and one id per part. A
head message with no parts has an empty list.¶
loose_sys_parts has one list per head message and one id per part of the
loose message. The loose form drops parts that loosen to nothing. The lists
are therefore not aligned with sys_parts by index. Compare loose part ids
as sets.¶
For anthropic.messages, the system prompt is one head message with one
text part per block. A part id is therefore a block id.¶
Equal tools give equal ids at any position, and the same tool in another
dialect gives the same id. The same ids with another order of tool_ids mean
that the tools were only reordered.¶
An implementation that provides them MUST pass vectors/v1-components.¶
Component ids are for identity and diagnostics: which tool was added, removed
or edited, and which system block changed. They are not cache keys for a
model's KV cache. KV state is positional: the state of a tool depends on every
token before it, so the same tool after a different prompt is not reusable
state for a standard engine. Prefix reuse belongs on head and nodes. A
component id MUST NOT be used as a key for KV state.¶
Open issue (decision 0006, open questions): A system or developer message
injected in the body gets a msg id but no part ids. Whether it should is not
decided.¶
Request (openai.chat, vector openai.chat/user-only):¶
{"model": "m", "messages": [{"role": "user", "content": "Hello, world"}]}
¶
The canonical form has no head message, no tools and one body message. The
CBOR of the body message M[0] (hexadecimal) is¶
a2 64 726f6c65 64 75736572 65 7061727473 81
a2 61 74 64 74657874 61 76 6c 48656c6c6f2c20776f726c64
¶
that is {"role": "user", "parts": [{"t": "text", "v": "Hello, world"}]}: map
of 2, text "role", text "user", text "parts", array of 1, map of 2, "t",
"text", "v", "Hello, world". The key role sorts before parts because its encoding is shorter.¶
With the test key of epoch 0 (Section 8.3), the empty scope, and label msg,
the HMAC input is¶
"kvsig/1" 00 "msg" 00 00 <the CBOR bytes above>
¶
where the second 00 after the label is the scope length (0), and the result
is msgs[0] = 0000bf6051d47a6368106ee45ecfd626f6: epoch byte 00, then the
first 16 bytes of the HMAC.¶
A deployment key is exactly 32 bytes. It MUST come from a cryptographically secure random source ([RFC4086]). It MUST be kept secret: it is the only protection of the ids against confirmation of guessed content (Section 11.1). A key MUST NOT be derived from a password or from any value that an outside party can guess, and MUST NOT be shared across deployments that are meant to be unlinkable (Section 10).¶
A key has an epoch, an integer from 0 to 255, which is the first byte of every id made with it. Epochs 1 to 255 are for deployment keys. Epoch 0 is reserved for published test keys: a deployment MUST NOT use epoch 0 for a real key. Two keys in one key ring MUST have distinct epochs. The epoch is not an input to the HMAC (Section 7.1). It only names the key. One secret under two epochs would give ids that differ in the first byte alone, so a deployment SHOULD NOT do that, and SHOULD NOT reuse an epoch number for a new secret while ids of the old secret can still be around.¶
Open issue: kvsig/1 has 255 deployment epochs. What a deployment does after it has used all of them is not defined.¶
Two keys are published for the test vectors. Both are public and MUST NOT protect real data.¶
| Name | Epoch | Key bytes |
|---|---|---|
test-0
|
0 |
00 01 02 ... 1f (the 32 bytes 0x00 to 0x1f) |
test-255
|
255 |
20 21 22 ... 3f (the 32 bytes 0x20 to 0x3f) |
test-255 has a different epoch so that a rotation can be tested. A
deployment MUST NOT use it as a real key, although 255 is a valid epoch.¶
A key ring is the current key and a list of accepted older keys. New ids are made with the current key. To look up an id made under an older key, a component computes the ids of the request under every key of the ring and matches each against its store. The first byte of a stored id tells which epoch made it. Rotation therefore works as follows.¶
Generate a new key with the next unused epoch.¶
Make it the current key, and keep the old key in the ring as accepted.¶
During the overlap, compute ids under every key of the ring (the cost is one derivation per key) and look up state under each.¶
When state keyed on old ids has aged out, remove the old key from the ring and destroy it.¶
A rotation changes every id of every request once. Cached state keyed on ids (for example prefix-cache affinity) is lost unless the overlap is used.¶
Where a key ring comes from (a file, a secret store, a control plane) and when it is refreshed is not specified. A key file format is not defined in this version (Annex C).¶
An implementation claims one level. Conformance is self-declared (Section 13.6).¶
Implements at least one dialect of Section 4.¶
Produces the canonical form of Sections 3 to 5, byte for byte, for all
vectors of that dialect with level 1.¶
Produces head, sys, tools, msgs and nodes for each test key
(Sections 7.3, 7.4 and 7.7), and the scope derivation (Section 7.1).¶
Returns the no-ids outcome where the vectors say so.¶
A reply is the assistant message of a provider response, canonicalised alone. The canonical form of a reply is one message, produced by these rules.¶
openai.chat: the message at choices[i].message is mapped as an assistant
message of the request (Section 4.2), with an empty call map.¶
anthropic.messages: the whole response is read. The role is the response's
role when it is a string, otherwise assistant. The parts are those of
content as for an assistant message (Section 4.4), with an empty call map.¶
openai.responses: the whole response is read. Its output items that are
assistant-side (Section 4.3) form one assistant message, in order, as in a
request. Other items are ignored. With no such item, the reply is an
assistant message with no parts.¶
The id of the reply is its message id. A reply that is over the size cap (its
CBOR over the cap) has no ids. The loose message id of a reply MUST equal the
loose message id of the same message in the next request. The exact message id
equals it when the client sends everything back. A client that does not send
reasoning back makes the exact ids differ; then only the loose id links the
reply to the next request. The exact field of a reply vector says which
holds.¶
Streamed responses are not covered: the vectors carry the assembled response.¶
Open issue (decision 0002, open question 1): A reply of a reasoning model links on loose ids, and the vectors cover both outcomes. Whether exact reply linkage should be defined for clients that do not send reasoning back is not decided.¶
An implementation MAY offer the component ids of Section 7.9 as a named
extension, components, on top of any level. It then MUST pass
vectors/v1-components. An implementation that does not offer it is still
conformant. The extension is proposed and may change before it is accepted.¶
An implementation MUST NOT fail the request path on a hostile or malformed request. It MUST return the no-ids outcome instead. Where a request gets ids, they MUST NOT depend on an optimisation (a cache, a native module).¶
A claim names the level, the vector set revision that the runner prints, and the extensions.¶
What an id is. An id is a keyed digest of content. To someone without the key it reveals nothing about the content, but it is not anonymous. Within a deployment, equal ids mean equal content. An id is a stable pseudonym for a piece of a conversation, and a log full of ids can be joined with other data. Operators SHOULD treat ids as personal data wherever the conversations are, and give them the retention and access rules of the logs that they describe.¶
Linkability across requests. Every request that shares a head and an
opening message shares conv. Every request in a conversation shares its
prefix node ids. A holder of the ids can therefore follow a conversation, a
user's conversations that start the same way, and a system prompt over time.
This is the purpose of the ids and the cost of them.¶
Dictionary and confirmation attacks. HMAC under a secret key is not reversible, but it is deterministic. Anyone who holds the deployment key can compute the id of any guessed message and compare. Short or common messages ("hi", a standard system prompt, a tool definition that ships with a popular harness) are therefore confirmed from their id by a key holder. The ids give no protection against a holder of the key. They protect against holders of ids who do not hold the key. A key SHOULD be held only by the components that must derive ids.¶
Cross-deployment unlinkability. Two deployments with different keys derive different ids for the same content, and cannot link them. The ids are not designed for identity across deployments: they are valid only for holders of one key. A deployment that shares a key with another deployment lets their ids be linked.¶
Cross-tenant linkability inside a deployment. Tenants that share a key and an empty scope get the same ids for the same content. Whoever sees ids of more than one tenant learns that two tenants sent the same message, the same system prompt, or the same tool definition. Component ids make this finer: a single shared tool is visible (decision 0006). A scope per tenant (Section 8.5) removes this.¶
Length and structure leakage. An id does not reveal the length of the
content it covers. The set of ids does show structure: the number of body
messages (the length of msgs and nodes), the number of tools and head
parts (the lists of component ids), whether a conversation has content, and
which messages repeat. Timing and the size of requests and responses are
outside the ids and leak independently. A deployment that must not reveal the
number of turns SHOULD NOT expose the lists.¶
Exposure of ids. Ids SHOULD NOT be sent to a party that is not a holder of
the key's trust domain, for example a third-party model provider, a customer
or a public trace backend. In particular conv SHOULD NOT be returned to
clients or written into a field that others will treat as a session id.¶
Not a session identifier. conv identifies content. Ids MUST NOT be used
as gen_ai.conversation.id in OpenTelemetry [OTEL-GENAI], and conv SHOULD NOT be used as any other identifier whose meaning is "this session". Two users can share a conv, a
session can change it (a compaction), and a pseudonym that looks like a session
id invites joins that the ids were not made for. A deployment that wants to
export an identifier for tracing SHOULD export a separate, random session id,
and MAY keep kvsig ids as attributes inside its own trust domain.¶
Data minimisation. Canonical forms and loose forms contain content. An implementation SHOULD NOT store them. Only the ids are needed after derivation.¶
A holder of the deployment key can compute the id of any content. Compromise of the key therefore lets an attacker confirm guesses against every id that was ever logged under it (Section 10), including ids from before the compromise. The ids themselves give no way to read content. The damage of a compromise is limited by the age of the logged ids, so keys SHOULD be rotated (Section 8.4), and logs of ids SHOULD have a retention limit. After a compromise the key MUST be replaced and the old ids treated as confirmable.¶
See Section 10. A key holder can test candidate messages: it derives the id of a guess and compares. Short, common or structured content (a greeting, a standard system prompt, a tool definition that ships with a popular harness) is easy to confirm. The more components hold the key, the larger the set of parties that can do this. A deployment SHOULD give the key only to components that derive or look up ids. A scope does not help against a key holder: it is not secret. It only separates the ids of tenants from each other.¶
An id holds the first 16 bytes (128 bits) of the 32-byte HMAC-SHA-256 output,
after the epoch byte. The truncation is fixed for kvsig/1. Without the key,
nobody can choose inputs that collide. Two different inputs collide by chance
with probability about n^2 / 2^129 among n ids under one key and scope, so
a collision is expected only after about 2^64 ids. This is not a practical risk
for caches and logs. The consequence of a collision would be that two different
prompts or messages are treated as one: a cache may reuse state that belongs to
another conversation. A deployment that shares a cache across a trust boundary
SHOULD NOT depend on ids alone for the isolation, and SHOULD use a scope per
tenant. The epoch byte adds no strength: it is not covered by the HMAC.¶
The HMAC input starts with the spec label, a label that names the id kind, and the scope length and scope, before the payload. Labels contain no zero byte, and the scope length is one byte, so two different (label, scope, payload) triples never give the same HMAC input. Exact and loose ids, and ids of different profile names, use different labels. A message id and a head id of the same bytes therefore still differ. A node id chains raw ids that include the epoch byte.¶
A request can be hostile in size or shape. Canonicalisation is linear in the size of the request, with these limits:¶
The canonical form is capped at 2 MiB by default (Section 5.4). Over the cap gives the no-ids outcome.¶
JSON values that are kept (tool arguments, schemas, opaque values) nest at most 128 containers. A deeper value gives the no-ids outcome. A string of arguments that nests far more (5000 levels) MUST also give the no-ids outcome and not crash the implementation.¶
The loose rules (removal of blocks and date lines, whitespace collapse) SHOULD run in time linear in the length of the text. The reference implementation does. An unclosed tag leaves the rest of the text as it is.¶
A number with thousands of digits is valid JSON. A parser MUST NOT fail on
it or loop. It is too large for a double and prints as null (the vector
args-huge-digit-string).¶
The cap does not bound the size of media data, because media is hashed and only its hash is in the canonical form. Base64 data that is decoded for hashing can be large. An implementation SHOULD bound the size of a request before it parses it, and SHOULD parse with a parser that has a depth limit.¶
Id caches, where used, SHOULD be bounded. The reference cache is bounded and holds ids only.¶
Ids SHOULD be logged only where the logs have the protection of the key's
trust domain. A log of ids is a log of equalities between conversations. It
SHOULD NOT be exported to systems that are outside the trust domain, and
SHOULD NOT be joined with identifiers of users without a reason. Raw keys
MUST NOT be logged. Implementations SHOULD keep key material out of
string conversions and error messages (the reference implementation redacts it
in its repr).¶
Ids do not authenticate a request. Anyone who can send content can send the content that gives a given id: sending the same prefix gives the same prefix node ids by design. Prefix reuse across tenants allows timing side channels on the cache. Ids do not remove them. A deployment SHOULD use a scope per tenant where tenants must not learn from cache timing about each other.¶
conv and the other ids identify content, not a session, and they are
pseudonyms of content. They MUST NOT be used as gen_ai.conversation.id, and
they SHOULD NOT be used as a session or user identifier, as an access-control
key, or as a secret. See Section 10.¶
This section applies from draft 0.1 (reference library 0.1.0) on.¶
There are three version numbers, and they move independently:¶
| Name | Example | What it versions |
|---|---|---|
| Spec label |
kvsig/1
|
Canonical form, canonical bytes, id derivation. It is hashed into every id. |
| Loose profile |
loose/1, loose/2
|
The loose table. Its name is hashed into every loose id. |
| Draft revision and library version | draft 0.1, kvsig 0.1.0 |
The text, the vector set revision and an implementation. |
What is stable. For the spec label kvsig/1 and the loose profile
loose/1, the canonical bytes and every id given by the vectors in
vectors/v1 (vector set revision 0.1, 232 vectors, listed in
vectors/v1/manifest.json with their hashes) are fixed. An implementation
that passes them today keeps passing them. Specifically:¶
No release changes the canonical bytes or the ids of any input under an
existing spec label and loose profile. A change that would, including one
that comes out of accepting a proposed decision, is published under a new
label (kvsig/2) or a new loose profile (loose/3), with its own vector
set. The old label or profile stays available by name.¶
The expected values of an existing vector never change. New vectors may be
added to vectors/v1, in a new vector set revision, only when they pin
what the current rules already give.¶
A reference library that disagrees with a vector has a bug, and the fix is a patch release.¶
Changing the library's default profile (for example to loose/2) is a
breaking change: before 1.0 it happens only in a minor release (0.x to
0.x+1), with a "Changed defaults" entry in the CHANGELOG.¶
What is not stable yet.¶
loose/2 (decision 0005, proposed, Section 6.5) ships in the reference
library as LOOSE_V2 but is experimental. It has no vector set, and its ids
may change until the decision is accepted and a loose/2 vector set is
published.¶
Dialects, part types and request fields that no vector covers. Their behaviour is the reference library's, and a later vector may pin it.¶
The Python API outside the ids it returns. It follows SemVer from 0.1.0 with the 0.x rule: a minor release may change the API, a patch release does not.¶
After the freeze (1.0) the vectors of a frozen spec version are immutable.¶
The vectors are the definition of the ids. This section summarises their format. The full format is in decision 0004 and vectors/README.md.¶
vectors/v1/<dialect>/<case>.json: one vector per file.
vectors/v1/manifest.json lists the spec label (kvsig/1), the format
number, the loose profile (loose/1), the vector set revision, the test
keys, and every file with its SHA-256, level, dialect and category.¶
vectors/v1-components/ has the same layout for the component ids
(Section 7.9), with its own manifest, which has the member
"extension": "components".¶
Every input is synthetic. The files are generated by the reference
implementation, and an independent cross-check that does not import the
library re-derives every id from the canonical form
(vectors/tools/xcheck.py).¶
| Field | Meaning |
|---|---|
id, spec, dialect, category, description
|
Name and purpose. |
level
|
The lowest conformance level that runs this vector (1, 2 or 3). |
input
|
The request as parsed JSON. |
input_raw_b64
|
The exact wire bytes, when the case needs them (lone surrogates, repeated member names, number forms, deep nesting). Then input is null. |
options.max_bytes
|
A size cap for this request (the default is 2 MiB). |
scope
|
cache_salt, tenant_b64 and the derived scope_b64. Absent means the empty scope. |
expect.none
|
True when the request gets no ids. |
expect.stateful
|
True for a Responses request that continues server-side history. |
expect.canonical_bytes_b64
|
The exact canonical form: the CBOR of {"head", "tools", "messages"}. These bytes are normative. |
expect.canonical
|
The same, as readable JSON. Byte strings appear as {"$hex": "..."}. |
expect.loose, expect.loose_bytes_b64
|
The same for the loose form (loose/1). |
expect.keys.<epoch>
|
The ids under each test key: head, sys, tools, msgs, nodes, loose_head, loose_sys, loose_tools, loose_msgs, loose_nodes, conv. A component vector adds tool_ids, loose_tool_ids, sys_parts, loose_sys_parts. |
equivalent_to
|
Vectors in other dialects with the same canonical form, so the same ids. |
relations
|
Claims between vectors: {"field", "other", "same"}. |
reply
|
Level 3 only: the response, matches_msg_index, exact, and the expected message ids. |
Ids in the vectors are the 34-character lowercase hexadecimal strings of Section 7.3.¶
conformance/run.py checks an implementation through a line protocol over
standard input and output (operations info, scope, canonicalize, ids
and reply_id). A thin adapter is all that an implementation needs. See
conformance/README.md. Byte values in the protocol
are base64 ([RFC4648]).¶
Where the rules were silent, the vectors record what the reference implementation does. Among them:¶
A result takes the index of the last call with the same id in one assistant
message (repeated-id-in-message).¶
Dates inside sentences stay (loose-date-in-sentence-kept).¶
A request at the size cap gets ids and one byte over gets none
(size-at-cap, size-over-cap).¶
128 nested containers give ids, 129 give none (depth-128-ok,
depth-129-none), and 5000 give none without a crash (depth-5000-none).¶
A client that sends reasoning back and one that does not both occur in the reply vectors.¶
Streamed responses, the legacy completions dialect, a request near the default cap, inputs that are not valid UTF-8 JSON, and key-ring lookup.¶
Conformance is self-declared. Run the runner at the level claimed, link the
output, and name the vector set revision that it prints (for example kvsig/1
revision 0.1).¶
There is no IANA registry for these values and this document makes no request to IANA. The lists below are maintained by the kvsig project in this repository. A value that is not listed is not defined by this specification.¶
| Name | Status |
|---|---|
openai.chat
|
defined (Section 4.2) |
openai.responses
|
defined (Section 4.3) |
anthropic.messages
|
defined (Section 4.4) |
openai.completions
|
reserved, no mapping |
t)
text, media, tool_call, tool_result, reasoning, opaque. Media
sources (src): bytes, url, file_id.¶
Exact: head, sys, tools, msg, node, and for the proposed extension
tool and part. Loose: the profile name, a colon and one of head, sys,
tools, msg, node, conv, and for the extension tool and part.¶
| Name | Status |
|---|---|
loose/1
|
stable, vector set vectors/v1
|
loose/2
|
experimental, no vector set (Section 6.5) |
| Label | Status |
|---|---|
kvsig/1
|
this document |
A new value is added by a pull request to this repository, after the comment period of the governance rules (at least 14 days for a normative change; GOVERNANCE.md).¶
A dialect name needs a mapping section like those of Section 4 and a set
of vectors. The name has the form <provider>.<api>.¶
A part type, a label or a media source changes the canonical form
or the derivation. It needs a new spec label (kvsig/2) unless it is an
extension that is defined to leave all existing ids unchanged, in which case
it needs its own vector set.¶
A loose profile needs a name, a table and a vector set. Any change to a table is a new profile name.¶
A spec label is a new version of this document with its own vectors.¶
Names of dialects, profiles and spec labels MUST NOT contain a zero byte, and profile names MUST NOT contain a colon.¶
Prefix caching in inference engines hashes token blocks. The vLLM prefix cache [VLLM-PREFIX] chains block hashes and offers a CBOR-based hash for reproducibility across languages, and the llm-d KV-cache indexer [LLM-D-KV] re-derives engine block keys outside the engine. kvsig works one level up, on messages before tokenisation, and uses CBOR for the same reason. The chained node ids are a Merkle chain in the way of a content-addressed log. IPLD uses deterministic CBOR for content ids [IPLD-DAG-CBOR]. Matrix [MATRIX-CANON] and the W3C Data Integrity work canonicalise JSON before hashing or signing. DSSE [DSSE] avoids canonicalisation by length-prefixed framing. The JSON number printing of Section 5.3 is that of JSON canonicalisation ([RFC8785]). The concept of a conversation identifier for telemetry exists in OpenTelemetry [OTEL-GENAI]; Section 10 says why a kvsig id is not that identifier. Provider APIs define the request formats of Section 4 ([OPENAI-CHAT], [OPENAI-RESPONSES], [ANTHROPIC-MESSAGES]).¶
The authors thank the maintainers and users of the engines, gateways and harnesses whose behaviour shaped these rules, and everyone who reviewed the decisions.¶
This document has no IANA actions. The lists of Section 14 are maintained in the kvsig repository, not by IANA.¶
The annexes are informative and are to follow:¶
A. OpenTelemetry mapping.¶
B. Reference pseudo-code.¶
C. Key file format. The reference implementations do not define one. Keys are passed to them as 32 raw bytes with an epoch, and where a key ring comes from is left to the deployment (Section 8.4). This annex will be written when an implementation defines a file format.¶
D. Lineage edge vocabulary.¶