pub struct RetryHint {
pub reason: String,
}Expand description
Metadata attached to an Outcome::Retry to explain why the agent
wants to retry.
Fields§
§reason: StringHuman-readable reason for the retry.
Implementations§
Source§impl RetryHint
impl RetryHint
Sourcepub fn new(reason: impl Into<String>) -> Self
pub fn new(reason: impl Into<String>) -> Self
Create a new hint with the given reason.
Examples found in repository?
examples/edit_loop.rs (line 82)
64 fn run(&mut self, mut state: Doc, ctx: &mut Ctx) -> StepResult<Doc> {
65 // Collect logs first, then clear. Reading logs() borrows &self,
66 let entries: Vec<String> = ctx.logs().to_vec();
67
68 for entry in &entries {
69 if entry.contains("wrold") {
70 state.text = state.text.replace("wrold", "world");
71 ctx.log("fixer: corrected 'wrold' -> 'world'");
72 }
73 if entry.contains("dcument") {
74 state.text = state.text.replace("dcument", "document");
75 ctx.log("fixer: corrected 'dcument' -> 'document'");
76 }
77 }
78
79 if !self.retried {
80 self.retried = true;
81 ctx.log("fixer: retrying to double-check fixes");
82 Ok((state, Outcome::Retry(RetryHint::new("double-checking"))))
83 } else {
84 self.retried = false;
85 Ok((state, Outcome::Next("validator")))
86 }
87 }Trait Implementations§
Auto Trait Implementations§
impl Freeze for RetryHint
impl RefUnwindSafe for RetryHint
impl Send for RetryHint
impl Sync for RetryHint
impl Unpin for RetryHint
impl UnsafeUnpin for RetryHint
impl UnwindSafe for RetryHint
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