#[non_exhaustive]pub enum OutputStrategy {
Auto,
Native,
Tool,
Prompted,
}Expand description
How the codec should ask the model to honour the schema.
Industry consensus (LangChain 1.0 ProviderStrategy/
ToolStrategy, pydantic-ai 1.90 NativeOutput/ToolOutput/
PromptedOutput/TextOutput, BAML SAP, Vercel AI SDK 5
generateObject, Instructor’s mode flag) converges on three
dispatch shapes plus an automatic picker:
Native— vendor-native structured output channel (OpenAItext.format = json_schema, GeminiresponseJsonSchema, Anthropicoutput_config.format = json_schema). Strictest; the vendor itself rejects malformed responses.Tool— single forced tool call whose input schema is the target schema. Mature on every vendor (the tool-call surface predates native structured output by a year+); slightly less efficient because the model emits a tool_use block instead of plain assistant text.Prompted— schema injected into the system prompt; the reply is parsed best-effort. Last resort for vendors with neither native nor tool support, and for “I want a typed answer but the model is non-reasoning” flows. Deferred to 1.1 —complete_typedrejects this strategy at runtime today.Auto— codec picks per-vendor at codec-construction time (NOT per request — per-request resolution would let the same logical request resolve differently across replays, breaking the SessionGraph event log’s deterministic-replay guarantee). The picked strategy is whatCodec::auto_output_strategy(model)returns.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Auto
Codec picks per-vendor at codec-construction time. Default.
Native
Vendor-native structured output channel.
Tool
Forced single tool call carrying the target schema.
Prompted
Schema injected into the system prompt (1.1 — currently rejected at encode time).
Trait Implementations§
Source§impl Clone for OutputStrategy
impl Clone for OutputStrategy
Source§fn clone(&self) -> OutputStrategy
fn clone(&self) -> OutputStrategy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OutputStrategy
impl Debug for OutputStrategy
Source§impl Default for OutputStrategy
impl Default for OutputStrategy
Source§fn default() -> OutputStrategy
fn default() -> OutputStrategy
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for OutputStrategy
impl<'de> Deserialize<'de> for OutputStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for OutputStrategy
impl PartialEq for OutputStrategy
Source§fn eq(&self, other: &OutputStrategy) -> bool
fn eq(&self, other: &OutputStrategy) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for OutputStrategy
impl Serialize for OutputStrategy
impl Copy for OutputStrategy
impl Eq for OutputStrategy
impl StructuralPartialEq for OutputStrategy
Auto Trait Implementations§
impl Freeze for OutputStrategy
impl RefUnwindSafe for OutputStrategy
impl Send for OutputStrategy
impl Sync for OutputStrategy
impl Unpin for OutputStrategy
impl UnsafeUnpin for OutputStrategy
impl UnwindSafe for OutputStrategy
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.