pub struct SessionOptions {Show 21 fields
pub provider: Option<String>,
pub model: Option<String>,
pub api_key: Option<String>,
pub thinking: Option<ThinkingLevel>,
pub system_prompt: Option<String>,
pub append_system_prompt: Option<String>,
pub enabled_tools: Option<Vec<String>>,
pub working_directory: Option<PathBuf>,
pub no_session: bool,
pub session_path: Option<PathBuf>,
pub session_dir: Option<PathBuf>,
pub extension_paths: Vec<PathBuf>,
pub extension_policy: Option<String>,
pub repair_policy: Option<String>,
pub include_cwd_in_prompt: bool,
pub max_tool_iterations: usize,
pub tool_factory: Option<Arc<dyn ToolFactory>>,
pub on_event: Option<Arc<dyn Fn(AgentEvent) + Send + Sync>>,
pub on_tool_start: Option<OnToolStart>,
pub on_tool_end: Option<OnToolEnd>,
pub on_stream_event: Option<OnStreamEvent>,
}Expand description
SDK session construction options.
These options provide the programmatic equivalent of the core CLI startup
path used in src/main.rs.
Fields§
§provider: Option<String>§model: Option<String>§api_key: Option<String>§thinking: Option<ThinkingLevel>§system_prompt: Option<String>§append_system_prompt: Option<String>§enabled_tools: Option<Vec<String>>§working_directory: Option<PathBuf>§no_session: bool§session_path: Option<PathBuf>§session_dir: Option<PathBuf>§extension_paths: Vec<PathBuf>§extension_policy: Option<String>§repair_policy: Option<String>§include_cwd_in_prompt: bool§max_tool_iterations: usize§tool_factory: Option<Arc<dyn ToolFactory>>Optional factory for the session’s ToolRegistry.
When None (the default), create_agent_session builds the
built-in tool set from SessionOptions::enabled_tools exactly
as it always has — existing callers are unaffected.
Setting this lets a downstream embedder layer custom tools onto
the registry: approval-gated wrappers around the built-ins, a
read-only “plan mode” subset, a Task tool that spawns nested
sandboxed sessions, etc. Implement ToolFactory on your own
Send + Sync type and call default_tool_registry from inside
it to inherit the current built-in resolution rules.
Wrapped in Arc because SessionOptions is cloned through
the session-handle pipeline and the factory may need to outlive
the options struct.
on_event: Option<Arc<dyn Fn(AgentEvent) + Send + Sync>>Session-level event listener invoked for every AgentEvent.
Unlike the per-prompt callback passed to AgentSessionHandle::prompt,
this fires for all prompts throughout the session lifetime.
on_tool_start: Option<OnToolStart>Typed callback invoked when tool execution starts.
on_tool_end: Option<OnToolEnd>Typed callback invoked when tool execution ends.
on_stream_event: Option<OnStreamEvent>Callback for raw provider StreamEvents.
Trait Implementations§
Source§impl Clone for SessionOptions
impl Clone for SessionOptions
Source§fn clone(&self) -> SessionOptions
fn clone(&self) -> SessionOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SessionOptions
impl !UnwindSafe for SessionOptions
impl Freeze for SessionOptions
impl Send for SessionOptions
impl Sync for SessionOptions
impl Unpin for SessionOptions
impl UnsafeUnpin for SessionOptions
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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