Expand description
The rules pairing a conversation’s tool calls with their results:
validation and repair of a message list, the same repair over entries
that keeps their ids (normalize), the calls a cut-short conversation
still owes, and where a window of it may start.
use rig_core::{conversation::pairing, message::Message};
pairing::validate(&[Message::user("Hello"), Message::assistant("Hi")])?;Structs§
- Normalized
entriesrepaired asrepairrepairs messages, keeping ids: what the conversation holds afterConversation::normalize.- Paired
- A history with its calls and results paired.
- Pairing
- How
pairreads a history.
Enums§
- Answer
Error - Why a batch of results does not answer a turn’s calls (
answers). - Pairing
Error - Why a history is not a canonical conversation, or what
pairrepaired. Seevalidate.
Constants§
- NO_
RESULT_ PROVIDED - The text of the result rig sends for a tool call nothing answered.
Functions§
- answers
- Whether
resultsanswerpendingexactly, one result per occurrence of an id in any order, matched aspairmatches them. - close_
pending - The user message closing
callsnothing answered: aNO_RESULT_PROVIDEDerror result per occurrence, in call order, exactly aspaircloses them. - close_
pending_ with close_pending, each error result sayingwhy, such as why the calls never ran.- normalize
entriesrepaired asrepairrepairs their messages, but that user entries side by side stay apart: an assistant entry directly after another is merged into it (the later stop standing) and keeps the first’s id, author and made-time; a result no call waits for is dropped, and an entry left empty with it; a made-up result for a call nothing answered goes into the next user entry, else a new entry byAuthor::rig; a system entry arriving while calls wait moves after the entries that answer them. A listrepairleaves as it is comes back unchanged.- pair
- The one rule for when a tool call is answered.
Noneis a turn the caller emptied; it ends waiting calls like a turn. - pending_
calls - The tool calls of the last assistant message in
messagesthat no later tool result answers, in call order: what a conversation cut short still owes the model. - repair
messagesread as a canonical conversation and repaired into onevalidateaccepts, losing no turn: the lenient load of a history from outside the protocol, such as a stored transcript, and the close of a run’s history at cancellation. Beyondpair, an assistant turn left directly after another is merged into it;repairsreports the input aspairread it.- safe_
start - The first index at or after
ata request may startmessagesfrom: past every tool result before the first assistant turn fromat, since its call is cut off, with any text or system message among them. Paired results later on are left alone.atpast the end is the end. - validate
- Rejects what
pairwould repair: consecutive assistant messages, a call nothing answered, and a result no waiting call asked for.