pub enum BeforeModelDecision {
Continue,
Modify(Request),
ShortCircuit(Assistant),
Abort(String),
}Expand description
ModelHooks::before_model decision.
Self::Modify is where a composition layer normalises history for the
provider it is about to call. Core applies visibility and the tool-exchange
grammar and stops there: it never rewrites a
Segment because a different provider
produced it, because deciding that one vendor’s thinking segment is unusable
by another requires knowing both vendors’ rules — a compat matrix core does
not and must not learn. A registration that changes model mid-session reads
BeforeModelScope::request, rewrites the segments its next provider cannot
accept, and re-freezes through
RequestPlan::try_into_request, which
is the only way to construct a Request and therefore cannot be bypassed.
Variants§
Continue
Continue with the current request.
Modify(Request)
Replace the request after runtime validation.
ShortCircuit(Assistant)
Supply assistant output without invoking the model.
AfterModelScope::generated is false, its
AfterModelScope::finish_reason is empty because no provider supplied a
label, and its completion classification is
CompletionReason::Unknown.
Tool-call identities and names must be nonempty. Model-visible identities may not repeat either within this record or anywhere in the frozen request history. The runtime rejects an invalid value as a typed, registration-attributed hook failure before anything is committed.
Abort(String)
Deliberately abort model invocation.