Expand description
Conversation validation and repair, assistant-turn classification, and constructors for real or synthetic tool results.
use rig_core::{message::Message, transcript::validate_canonical};
validate_canonical(&[Message::user("Hello"), Message::assistant("Hi")])?;Enums§
- Transcript
Error - Why a history is not a canonical transcript. See
validate_canonical.
Constants§
- TOOL_
NOT_ EXECUTED_ DUE_ TO_ INVALID_ PEER - The result every other call of a turn gets when one call was retried or skipped: none of the turn’s calls ran.
Functions§
- assistant_
text_ from_ choice - The text parts of an assistant turn, concatenated.
- invalid_
arguments_ feedback - What the model reads when its call to
toolsentraw, arguments that are not a JSON object: the tool never ran, and the model calls it again. - invalid_
call_ feedback - The tool results answering a turn with an invalid call, in call order:
feedbackfor the callinvalid,TOOL_NOT_EXECUTED_DUE_TO_INVALID_PEERfor every other call. Empty whencontenthas no tool calls. - is_
empty_ assistant_ turn - Whether a generated assistant turn is empty: every part is blank
(
AssistantContent::is_blank, the rule replay drops parts by). An empty turn must not enter history. - not_
executed - The result of a call the run did not execute because a call beside it was invalid.
- tool_
result_ message - Constructs the error result of a call that never ran, its text verbatim, such as recovery feedback or a skip reason. JSON-shaped text is not reinterpreted as structured or multimodal output.
- tool_
result_ output - Shape a tool’s result as the tool result the model reads, without reparsing text. Anything but a success is an error result.
- validate_
canonical - Rejects consecutive assistant messages, unanswered tool-call IDs, and results without a pending call. Each pending ID must be answered once in the next user message, before another assistant message or the end of history. System messages reset the consecutive-assistant check but retain pending calls. Duplicate call IDs are treated as one pending ID.