Skip to main content

objectiveai_sdk/agent/codex_sdk/
effort.rs

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