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 serde::{Deserialize, Serialize};
8use schemars::JsonSchema;
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(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Hash, JsonSchema)]
18#[serde(rename_all = "snake_case")]
19#[schemars(rename = "agent.OutputMode")]
20pub enum OutputMode {
21    /// The model is instructed via the prompt to output a specific key.
22    ///
23    /// This is the default and most widely supported mode.
24    #[schemars(title = "Instruction")]
25    Instruction,
26    /// A JSON schema response format is used with an enum of possible keys.
27    ///
28    /// Requires model support for structured JSON output.
29    #[schemars(title = "JsonSchema")]
30    JsonSchema,
31    /// A forced tool call with an argument schema containing possible keys.
32    ///
33    /// Requires model support for tool/function calling.
34    #[schemars(title = "ToolCall")]
35    ToolCall,
36}
37
38impl std::default::Default for OutputMode {
39    fn default() -> Self {
40        OutputMode::Instruction
41    }
42}
43
44impl From<super::openrouter::OutputMode> for OutputMode {
45    fn from(mode: super::openrouter::OutputMode) -> Self {
46        match mode {
47            super::openrouter::OutputMode::Instruction => {
48                OutputMode::Instruction
49            }
50            super::openrouter::OutputMode::JsonSchema => OutputMode::JsonSchema,
51            super::openrouter::OutputMode::ToolCall => OutputMode::ToolCall,
52        }
53    }
54}
55
56impl From<super::claude_agent_sdk::OutputMode> for OutputMode {
57    fn from(mode: super::claude_agent_sdk::OutputMode) -> Self {
58        match mode {
59            super::claude_agent_sdk::OutputMode::Instruction => {
60                OutputMode::Instruction
61            }
62        }
63    }
64}
65
66impl From<super::codex_sdk::OutputMode> for OutputMode {
67    fn from(mode: super::codex_sdk::OutputMode) -> Self {
68        match mode {
69            super::codex_sdk::OutputMode::Instruction => OutputMode::Instruction,
70        }
71    }
72}
73
74impl From<super::mock::OutputMode> for OutputMode {
75    fn from(mode: super::mock::OutputMode) -> Self {
76        match mode {
77            super::mock::OutputMode::Instruction => OutputMode::Instruction,
78            super::mock::OutputMode::JsonSchema => OutputMode::JsonSchema,
79            super::mock::OutputMode::ToolCall => OutputMode::ToolCall,
80        }
81    }
82}