pub struct ModelSelection<'a> {
pub prompt: &'a Message,
pub history: &'a [Message],
pub request_patch: Option<&'a RequestPatch>,
pub previous_model: Option<&'a ModelHandle>,
pub default_model: &'a ModelHandle,
pub selected_model: &'a ModelHandle,
}Expand description
Model-selection event resolved after completion-call hooks and before request preparation.
The runner default is the first candidate. A HookStack threads every
ModelSelectionAction::Select into later hooks in registration order, so
selected_model always reflects all earlier decisions for this event.
Ordering per CallModel step: completion-call hooks resolve first; only if
they proceed does this event fire, carrying the merged RequestPatch in
request_patch; only after selection resolves does
request preparation run against the selected model’s captured
ProviderCapabilities, and only
then is the attempt issued. Selection therefore runs once per CallModel
step whose completion-call hooks proceed — including model-turn retries and
post-tool calls — and never after a completion-call stop.
Selection is synchronous, local, and non-blocking: a hook may read and
write the run Scratchpad, but must not perform blocking I/O. In-flight
attempts never rebind — the selected handle is cloned into the prepared
attempt and executes it to completion.
previous_model reflects issued attempts only: it advances immediately
before the selected model’s unary or streaming operation is invoked, so a
provider attempt that returns an error still counts, while a
completion-call stop, a selection stop, or a request-preparation failure
does not. An extraction or run default set via using_model(...) is the
default candidate for every retry, not a hard pin: selection hooks may
override it on each retry.
Fields§
§prompt: &'a MessagePrompt for the pending model call.
history: &'a [Message]Canonical history visible to the pending model call.
request_patch: Option<&'a RequestPatch>Merged per-turn request patch from this step’s completion-call hooks (in hook registration order), when any hook patched the request.
previous_model: Option<&'a ModelHandle>Model that executed the preceding issued attempt in this run, if any.
default_model: &'a ModelHandleRunner default used as the initial candidate for this call.
selected_model: &'a ModelHandleCandidate after all earlier model-selection hooks.
Implementations§
Source§impl<'a> ModelSelection<'a>
impl<'a> ModelSelection<'a>
Sourcepub fn new(
prompt: &'a Message,
history: &'a [Message],
request_patch: Option<&'a RequestPatch>,
previous_model: Option<&'a ModelHandle>,
default_model: &'a ModelHandle,
selected_model: &'a ModelHandle,
) -> Self
pub fn new( prompt: &'a Message, history: &'a [Message], request_patch: Option<&'a RequestPatch>, previous_model: Option<&'a ModelHandle>, default_model: &'a ModelHandle, selected_model: &'a ModelHandle, ) -> Self
Construct a ModelSelection event from its parts.
Provided so that custom model-selection routers can be unit-tested outside this crate without restating every field.
Trait Implementations§
Source§impl<'a> Clone for ModelSelection<'a>
impl<'a> Clone for ModelSelection<'a>
Source§fn clone(&self) -> ModelSelection<'a>
fn clone(&self) -> ModelSelection<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more