nemo_gym.token_id_capture.fingerprint
nemo_gym.token_id_capture.fingerprint
Fingerprint conversation content across serving dialects.
These are pure functions over message lists. They hold no state and read no store. Any server may import them. Lineage state stays confined to the capture locus and the finalizer.
assistant_fingerprint hashes only model-authored turns.
It identifies the call that produced the last model-authored turn.
conversation_digest hashes every turn, including tool results.
A parent resolver uses it to verify context before reusing tokens.
Chat, Responses, and Anthropic shapes normalize to the same hash input. The hash layout is tagged and length-delimited. No concatenation of fields can collide with another field boundary.
Module Contents
Functions
Data
API
Serialize JSON-compatible prompt content without losing structure.
Return typed content parts without discarding prompt-shaping blocks.
Tool calls are normalized separately by _tools_of.
Tool results are normalized separately by _tool_results_of.
Return whether the model produced this item.
Chat and Anthropic use the assistant role.
Responses tool calls are roleless function_call items.
Return tool result identities and payloads across dialects.
Responses stores results in standalone function_call_output items.
Anthropic stores results in tool_result content blocks.
Chat stores results as plain message content.
Return tool calls as (id, name, canonical arguments) tuples.
Chat stores calls in the message’s tool_calls field.
Anthropic stores calls in tool_use content blocks.
Responses stores each call as a standalone function_call item.
Hash one tagged, length-delimited UTF-8 field.
Fingerprint the model-authored turns of a request, in order.
The fingerprint identifies the call that produced the last model-authored turn. User and tool content is excluded from the lookup key. Dialect-specific tool-call shapes normalize to the same hash input.
Normalize a tool call’s arguments for comparison only.
Harnesses can reserialize tool-call arguments between turns. Comparison uses sorted-key JSON with normalized separators. The record retains the model’s original string.
Hash every turn of a conversation, model-authored or not.
assistant_fingerprint ignores user and tool content.
This digest covers that omitted context.
A mismatch rejects the parent before its tokens are reused.