pub struct AutoContinueMiddleware { /* private fields */ }Expand description
Middleware that automatically injects a continuation message when the LLM
response is truncated by the token limit (e.g. max_tokens / length)
and no tool calls are present.
This turns a silent truncation into an automatic retry: the react loop will push the follow-up as a user message and call the LLM again.
§When it triggers
finish_reasonisTruncatedandtool_callsis empty (tool-call truncation is already handled by the react-loop’s built-in truncation guard, which injects error results instead of executing incomplete tool calls).
§Usage
ⓘ
use agent_base::engine::{AgentBuilder, auto_continue::AutoContinueMiddleware};
let runtime = AgentBuilder::new(client)
.middleware(AutoContinueMiddleware::new())
.build()?;Implementations§
Trait Implementations§
Source§impl Default for AutoContinueMiddleware
impl Default for AutoContinueMiddleware
Source§impl Middleware for AutoContinueMiddleware
impl Middleware for AutoContinueMiddleware
fn on_post_llm<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut PostLlmCtx,
) -> Pin<Box<dyn Future<Output = AgentResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_user_message<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 mut UserMessageCtx,
) -> Pin<Box<dyn Future<Output = AgentResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_pre_llm<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 mut PreLlmCtx,
) -> Pin<Box<dyn Future<Output = AgentResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for AutoContinueMiddleware
impl RefUnwindSafe for AutoContinueMiddleware
impl Send for AutoContinueMiddleware
impl Sync for AutoContinueMiddleware
impl Unpin for AutoContinueMiddleware
impl UnsafeUnpin for AutoContinueMiddleware
impl UnwindSafe for AutoContinueMiddleware
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