Skip to main content

SessionQuery

Struct SessionQuery 

Source
pub struct SessionQuery<'s, 'a> { /* private fields */ }
Expand description

Builder for a follow-up query within a session.

This wraps a QueryCommand with --resume pre-set. Session-related methods (.continue_session(), .session_id(), .fork_session(), .resume()) are intentionally not exposed, preventing conflicting flags at the type level.

All other QueryCommand options are available via delegation.

Implementations§

Source§

impl<'s, 'a> SessionQuery<'s, 'a>

Source

pub fn model(self, model: impl Into<String>) -> Self

Set the model to use.

Source

pub fn system_prompt(self, prompt: impl Into<String>) -> Self

Set a custom system prompt.

Source

pub fn append_system_prompt(self, prompt: impl Into<String>) -> Self

Append to the default system prompt.

Source

pub fn output_format(self, format: OutputFormat) -> Self

Set the output format.

Source

pub fn max_budget_usd(self, budget: f64) -> Self

Set the maximum budget in USD.

Source

pub fn permission_mode(self, mode: PermissionMode) -> Self

Set the permission mode.

Source

pub fn allowed_tools( self, tools: impl IntoIterator<Item = impl Into<String>>, ) -> Self

Add allowed tools.

Source

pub fn allowed_tool(self, tool: impl Into<String>) -> Self

Add a single allowed tool.

Source

pub fn disallowed_tools( self, tools: impl IntoIterator<Item = impl Into<String>>, ) -> Self

Add disallowed tools.

Source

pub fn mcp_config(self, path: impl Into<String>) -> Self

Add an MCP config file path.

Source

pub fn add_dir(self, dir: impl Into<String>) -> Self

Add an additional directory for tool access.

Source

pub fn effort(self, effort: Effort) -> Self

Set the effort level.

Source

pub fn max_turns(self, turns: u32) -> Self

Set the maximum number of turns.

Source

pub fn json_schema(self, schema: impl Into<String>) -> Self

Set a JSON schema for structured output validation.

Source

pub fn fallback_model(self, model: impl Into<String>) -> Self

Set a fallback model.

Source

pub fn no_session_persistence(self) -> Self

Disable session persistence.

Source

pub fn dangerously_skip_permissions(self) -> Self

Bypass all permission checks.

Source

pub fn agent(self, agent: impl Into<String>) -> Self

Set the agent for the session.

Source

pub fn agents_json(self, json: impl Into<String>) -> Self

Set custom agents as a JSON object.

Source

pub fn tools(self, tools: impl IntoIterator<Item = impl Into<String>>) -> Self

Set the list of available built-in tools.

Source

pub fn file(self, spec: impl Into<String>) -> Self

Add a file resource to download at startup.

Source

pub fn include_partial_messages(self) -> Self

Include partial message chunks as they arrive.

Source

pub fn input_format(self, format: InputFormat) -> Self

Set the input format.

Source

pub fn strict_mcp_config(self) -> Self

Only use MCP servers from --mcp-config.

Source

pub fn settings(self, settings: impl Into<String>) -> Self

Path to a settings JSON file or a JSON string.

Source

pub fn retry(self, policy: RetryPolicy) -> Self

Set a per-command retry policy.

Source

pub async fn execute(self) -> Result<QueryResult>

Execute the query, updating the session’s cumulative cost and turns.

Trait Implementations§

Source§

impl<'s, 'a> Debug for SessionQuery<'s, 'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s, 'a> Freeze for SessionQuery<'s, 'a>

§

impl<'s, 'a> RefUnwindSafe for SessionQuery<'s, 'a>

§

impl<'s, 'a> Send for SessionQuery<'s, 'a>

§

impl<'s, 'a> Sync for SessionQuery<'s, 'a>

§

impl<'s, 'a> Unpin for SessionQuery<'s, 'a>

§

impl<'s, 'a> UnsafeUnpin for SessionQuery<'s, 'a>

§

impl<'s, 'a> !UnwindSafe for SessionQuery<'s, 'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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