Skip to main content

codex/
thread_options.rs

1use serde::{Deserialize, Serialize};
2
3/// Approval policy used by Codex tool execution.
4#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
5pub enum ApprovalMode {
6    /// Never prompt and never escalate automatically.
7    #[serde(rename = "never")]
8    Never,
9    /// Ask for approval only when explicitly requested by the model/tool.
10    #[serde(rename = "on-request")]
11    OnRequest,
12    /// Ask for approval when a tool action fails and escalation is needed.
13    #[serde(rename = "on-failure")]
14    OnFailure,
15    /// Treat operations as untrusted and require strict approval behavior.
16    #[serde(rename = "untrusted")]
17    Untrusted,
18}
19
20/// Filesystem sandbox level for a thread.
21#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
22pub enum SandboxMode {
23    /// Read-only sandbox.
24    #[serde(rename = "read-only")]
25    ReadOnly,
26    /// Writable sandbox scoped to the workspace.
27    #[serde(rename = "workspace-write")]
28    WorkspaceWrite,
29    /// Full filesystem access without sandbox restrictions.
30    #[serde(rename = "danger-full-access")]
31    DangerFullAccess,
32}
33
34/// Reasoning effort level requested from the model.
35#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
36pub enum ModelReasoningEffort {
37    /// Minimal reasoning.
38    #[serde(rename = "minimal")]
39    Minimal,
40    /// Low reasoning effort.
41    #[serde(rename = "low")]
42    Low,
43    /// Medium reasoning effort.
44    #[serde(rename = "medium")]
45    Medium,
46    /// High reasoning effort.
47    #[serde(rename = "high")]
48    High,
49    /// Extra-high reasoning effort.
50    #[serde(rename = "xhigh")]
51    XHigh,
52}
53
54/// Web search mode for a thread.
55#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
56pub enum WebSearchMode {
57    /// Disable web search.
58    #[serde(rename = "disabled")]
59    Disabled,
60    /// Use cached web search results when available.
61    #[serde(rename = "cached")]
62    Cached,
63    /// Enable live web search.
64    #[serde(rename = "live")]
65    Live,
66}
67
68/// Per-thread options passed to `codex exec`.
69#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
70pub struct ThreadOptions {
71    /// Model name used for turns in this thread.
72    pub model: Option<String>,
73    /// Filesystem sandbox mode.
74    pub sandbox_mode: Option<SandboxMode>,
75    /// Working directory used by Codex.
76    pub working_directory: Option<String>,
77    /// Whether to skip the Git repository check.
78    pub skip_git_repo_check: Option<bool>,
79    /// Model reasoning effort override.
80    pub model_reasoning_effort: Option<ModelReasoningEffort>,
81    /// Enables/disables network access within workspace-write sandbox mode.
82    pub network_access_enabled: Option<bool>,
83    /// Preferred web search mode.
84    pub web_search_mode: Option<WebSearchMode>,
85    /// Legacy boolean web search toggle used when `web_search_mode` is unset.
86    pub web_search_enabled: Option<bool>,
87    /// Approval policy override.
88    pub approval_policy: Option<ApprovalMode>,
89    /// Additional directories to expose to the agent.
90    pub additional_directories: Option<Vec<String>>,
91}