pub trait RetryHandler: Send + Sync {
// Required method
fn on_validation_error(
&self,
attempt: u32,
raw_json: &str,
error: &StructuredErrorKind,
messages: &[InputItem],
) -> Option<Vec<InputItem>>;
}Expand description
Handler for customizing retry behavior on validation failures.
Implement this trait to customize how retry messages are constructed when validation fails. The default implementation appends a simple error message asking the model to correct its output.
Required Methods§
Sourcefn on_validation_error(
&self,
attempt: u32,
raw_json: &str,
error: &StructuredErrorKind,
messages: &[InputItem],
) -> Option<Vec<InputItem>>
fn on_validation_error( &self, attempt: u32, raw_json: &str, error: &StructuredErrorKind, messages: &[InputItem], ) -> Option<Vec<InputItem>>
Called when validation fails. Returns messages to append to the conversation
for the retry, or None to stop retrying immediately.
§Arguments
attempt- Current attempt number (1-based)raw_json- The raw JSON that failed validationerror- The validation/decode error that occurredmessages- The original conversation messages