pub struct MessagePairValidator;Expand description
Validates and repairs structural integrity of flat API message lists.
Implementations§
Source§impl MessagePairValidator
impl MessagePairValidator
Sourcepub fn validate_tool_results_complete(
tool_calls: &[Value],
tool_results_by_id: &mut HashMap<String, Value>,
)
pub fn validate_tool_results_complete( tool_calls: &[Value], tool_results_by_id: &mut HashMap<String, Value>, )
Ensure every tool_call has an entry in results. Fill missing with synthetic errors.
This is the pre-batch-add guard. Call BEFORE iterating tool_calls to add results to history.
Sourcepub fn validate(messages: &[ApiMessage]) -> ValidationResult
pub fn validate(messages: &[ApiMessage]) -> ValidationResult
Validate structural integrity of an API message list.
Single forward pass checking:
- Every tool_call ID from assistant messages has a matching tool result
- No orphaned tool results without a preceding tool_call
- Consecutive same-role messages (warning only)
Sourcepub fn repair(messages: &[ApiMessage]) -> (Vec<ApiMessage>, ValidationResult)
pub fn repair(messages: &[ApiMessage]) -> (Vec<ApiMessage>, ValidationResult)
Validate and repair an API message list.
- MISSING_TOOL_RESULT: Insert synthetic tool result after the assistant’s tool results.
- ORPHANED_TOOL_RESULT: Remove the orphaned message.
Auto Trait Implementations§
impl Freeze for MessagePairValidator
impl RefUnwindSafe for MessagePairValidator
impl Send for MessagePairValidator
impl Sync for MessagePairValidator
impl Unpin for MessagePairValidator
impl UnsafeUnpin for MessagePairValidator
impl UnwindSafe for MessagePairValidator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more