Skip to main content

RoundStrategy

Trait RoundStrategy 

Source
pub trait RoundStrategy: Send + Sync {
    // Required method
    fn on_round<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: RoundContext<'life1>,
    ) -> Pin<Box<dyn Future<Output = RoundDecision> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

The per-turn steering seam, whole: the trait a host implements and every type its signatures make that host name.

Re-exported rather than wrapped, under the rule stated on CancellationToken — a mentra type basis’s surface asks a caller to write is a name basis re-exports, or the caller pins mentra in their own manifest to spell it. And like the token, a strategy is an identity rather than a value: TurnOptions::with_round_strategy hands mentra the caller’s own Arc, so a basis-owned mirror of RoundDecision would be a translation layer with opinions of its own — the opposite of a seam.

The set is exactly what implementing costs. RoundStrategy is the trait (spelled with async_trait, which basis already re-exports); RoundContext and RoundBoundary are its question; RoundDecision, RoundAdjustment, ReasoningChange and RoundToolResult are its vocabulary for answering. The last three are here because the vocabulary’s own signatures demand them: RoundDecision::inject takes ContentBlocks, RoundAdjustment::with_model a ModelInfo, and ReasoningChange::Set a ReasoningOptions — whose effort field an Effort converts into, so switching effort mid-run never names mentra’s own level enum. A host-supplied policy invoked at each round boundary of a single Agent::run invocation.

The strategy is carried on RunOptions and so is bound to exactly one run: its state lives and dies with that run and can never leak through a pooled Runtime into another run. Its absence — the None default — reproduces mentra’s built-in round loop exactly.

At each boundary the strategy may continue, inject corrective context, switch the next round’s model or reasoning via a RoundAdjustment, or request a graceful stop. Every decision still passes through the run’s existing budget, cancellation, and deadline checks; an injected round is a normal round in every respect.

Required Methods§

Source

fn on_round<'life0, 'life1, 'async_trait>( &'life0 self, ctx: RoundContext<'life1>, ) -> Pin<Box<dyn Future<Output = RoundDecision> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Decide how the run should proceed at the given boundary.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§