Skip to main content

Config

Struct Config 

Source
pub struct Config {
Show 17 fields pub workspace: PathBuf, pub api_base: String, pub api_key: Option<String>, pub model: String, pub provider_type: String, pub preset: Option<String>, pub max_steps: usize, pub temperature: f64, pub system_prompt: String, pub retry_max: usize, pub retry_initial_backoff_secs: u64, pub retry_max_backoff_secs: u64, pub shell_timeout_secs: u64, pub headless: bool, pub memory_summary_limit: usize, pub thinking_budget: Option<u32>, pub session_name: Option<String>,
}

Fields§

§workspace: PathBuf§api_base: String§api_key: Option<String>§model: String§provider_type: String§preset: Option<String>

Preset id resolved from provider.preset in the config file. None when the user did not opt in (or the file was absent).

§max_steps: usize§temperature: f64§system_prompt: String§retry_max: usize§retry_initial_backoff_secs: u64§retry_max_backoff_secs: u64§shell_timeout_secs: u64§headless: bool

Run in headless mode: interactive tools go through external hooks instead of waiting for terminal input. If no hook approves the call, the tool is auto-denied.

§memory_summary_limit: usize§thinking_budget: Option<u32>

Extended thinking budget for models that support it (e.g. Anthropic claude-3-7). None = model default; Some(0) = disable thinking; Some(n) = budget_tokens.

§session_name: Option<String>

Optional display name for the session, shown in the /resume picker.

Implementations§

Source§

impl Config

Source

pub fn from_env() -> Result<Self>

Load from environment, with config file (~/.recursive/config.toml) as fallback.

Precedence (highest first), applied to api_base / api_key / model / provider_type:

  1. env var (e.g. RECURSIVE_API_BASE, OPENAI_API_KEY)
  2. explicit field in the file’s [provider] section
  3. preset field — provider.preset = "<id>" looks up the bundled providers.toml and takes its api_base / default_model / provider_type. For api_key, step 3 instead consults std::env::var(preset.key_env) (e.g. DEEPSEEK_API_KEY).
  4. hardcoded default

The api_key chain is asymmetric: the generic env vars in step 1 (RECURSIVE_API_KEY / OPENAI_API_KEY) rank above the file’s explicit api_key, but a preset’s specific env var in step 3 ranks below it. Inverting step 3 would silently override a user’s api_key = "sk-old" whenever DEEPSEEK_API_KEY happened to be in their shell.

The API key is optional here so commands that don’t need the LLM (e.g. tools, config) still run.

Source

pub fn require_api_key(&self) -> Result<&str>

Return the API key or a descriptive error if none was configured.

Source

pub fn validate_for_agent(&self) -> Result<(), String>

Validate that the config has enough information to run the agent. Returns a user-friendly error message if not.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more