Skip to main content

objectiveai_sdk/agent/codex_sdk/
effort.rs

1//! Effort settings for Codex SDK Agent output.
2
3use serde::{Deserialize, Serialize};
4use schemars::JsonSchema;
5
6/// Reasoning-effort level for the Codex model. Maps to Codex's
7/// `model_reasoning_effort` (see `openai_codex_sdk` `ModelReasoningEffort`).
8///
9/// `Medium` is the default and is normalized to `None` during preparation
10/// for content-addressing stability.
11#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema, arbitrary::Arbitrary)]
12#[schemars(rename = "agent.codex_sdk.Effort")]
13pub enum Effort {
14    /// Minimal reasoning, fastest responses.
15    #[schemars(title = "Minimal")]
16    #[serde(rename = "minimal")]
17    Minimal,
18    /// Low reasoning effort.
19    #[schemars(title = "Low")]
20    #[serde(rename = "low")]
21    Low,
22    /// Balanced reasoning (default, normalized away during preparation).
23    #[schemars(title = "Medium")]
24    #[serde(rename = "medium")]
25    #[default]
26    Medium,
27    /// High reasoning effort.
28    #[schemars(title = "High")]
29    #[serde(rename = "high")]
30    High,
31}
32
33impl Effort {
34    /// Normalizes effort for deterministic hashing. The default `Medium`
35    /// value is normalized to `None`.
36    pub fn prepare(self) -> Option<Self> {
37        if let Effort::Medium = self {
38            None
39        } else {
40            Some(self)
41        }
42    }
43
44    /// Validates the effort setting (always succeeds).
45    pub fn validate(&self) -> Result<(), String> {
46        Ok(())
47    }
48
49    /// Returns the wire-string representation of the effort level.
50    pub fn as_str(&self) -> &'static str {
51        match self {
52            Effort::Minimal => "minimal",
53            Effort::Low => "low",
54            Effort::Medium => "medium",
55            Effort::High => "high",
56        }
57    }
58}