Skip to main content

objectiveai_sdk/agent/
output_mode.rs

1//! Output mode configuration for vector completions.
2//!
3//! The output mode determines how the LLM is constrained to select from
4//! a set of predefined responses during vector completion. This setting
5//! is **only used for vector completions** and is ignored for agent completions.
6
7use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9
10/// The method used to constrain LLM output to valid response keys.
11///
12/// In vector completions, the model must select from a predefined set of
13/// responses. This enum controls *how* that constraint is enforced.
14///
15/// **Note:** This setting is only relevant for vector completions and is
16/// completely ignored for agent completions.
17#[derive(
18    Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Hash, JsonSchema,
19)]
20#[serde(rename_all = "snake_case")]
21#[schemars(rename = "agent.OutputMode")]
22pub enum OutputMode {
23    /// The model is instructed via the prompt to output a specific key.
24    ///
25    /// This is the default and most widely supported mode.
26    #[schemars(title = "Instruction")]
27    Instruction,
28    /// A JSON schema response format is used with an enum of possible keys.
29    ///
30    /// Requires model support for structured JSON output.
31    #[schemars(title = "JsonSchema")]
32    JsonSchema,
33    /// A forced tool call with an argument schema containing possible keys.
34    ///
35    /// Requires model support for tool/function calling.
36    #[schemars(title = "ToolCall")]
37    ToolCall,
38}
39
40impl std::default::Default for OutputMode {
41    fn default() -> Self {
42        OutputMode::Instruction
43    }
44}
45
46impl From<super::openrouter::OutputMode> for OutputMode {
47    fn from(mode: super::openrouter::OutputMode) -> Self {
48        match mode {
49            super::openrouter::OutputMode::Instruction => {
50                OutputMode::Instruction
51            }
52            super::openrouter::OutputMode::JsonSchema => OutputMode::JsonSchema,
53            super::openrouter::OutputMode::ToolCall => OutputMode::ToolCall,
54        }
55    }
56}
57
58impl From<super::claude_agent_sdk::OutputMode> for OutputMode {
59    fn from(mode: super::claude_agent_sdk::OutputMode) -> Self {
60        match mode {
61            super::claude_agent_sdk::OutputMode::Instruction => {
62                OutputMode::Instruction
63            }
64        }
65    }
66}
67
68impl From<super::codex_sdk::OutputMode> for OutputMode {
69    fn from(mode: super::codex_sdk::OutputMode) -> Self {
70        match mode {
71            super::codex_sdk::OutputMode::Instruction => {
72                OutputMode::Instruction
73            }
74        }
75    }
76}
77
78impl From<super::mock::OutputMode> for OutputMode {
79    fn from(mode: super::mock::OutputMode) -> Self {
80        match mode {
81            super::mock::OutputMode::Instruction => OutputMode::Instruction,
82            super::mock::OutputMode::JsonSchema => OutputMode::JsonSchema,
83            super::mock::OutputMode::ToolCall => OutputMode::ToolCall,
84        }
85    }
86}