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>
impl<'s, 'a> SessionQuery<'s, 'a>
Sourcepub fn system_prompt(self, prompt: impl Into<String>) -> Self
pub fn system_prompt(self, prompt: impl Into<String>) -> Self
Set a custom system prompt.
Sourcepub fn append_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn append_system_prompt(self, prompt: impl Into<String>) -> Self
Append to the default system prompt.
Sourcepub fn output_format(self, format: OutputFormat) -> Self
pub fn output_format(self, format: OutputFormat) -> Self
Set the output format.
Sourcepub fn max_budget_usd(self, budget: f64) -> Self
pub fn max_budget_usd(self, budget: f64) -> Self
Set the maximum budget in USD.
Sourcepub fn permission_mode(self, mode: PermissionMode) -> Self
pub fn permission_mode(self, mode: PermissionMode) -> Self
Set the permission mode.
Sourcepub fn allowed_tools(
self,
tools: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn allowed_tools( self, tools: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Add allowed tools.
Sourcepub fn allowed_tool(self, tool: impl Into<String>) -> Self
pub fn allowed_tool(self, tool: impl Into<String>) -> Self
Add a single allowed tool.
Sourcepub fn disallowed_tools(
self,
tools: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn disallowed_tools( self, tools: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Add disallowed tools.
Sourcepub fn mcp_config(self, path: impl Into<String>) -> Self
pub fn mcp_config(self, path: impl Into<String>) -> Self
Add an MCP config file path.
Sourcepub fn add_dir(self, dir: impl Into<String>) -> Self
pub fn add_dir(self, dir: impl Into<String>) -> Self
Add an additional directory for tool access.
Sourcepub fn json_schema(self, schema: impl Into<String>) -> Self
pub fn json_schema(self, schema: impl Into<String>) -> Self
Set a JSON schema for structured output validation.
Sourcepub fn fallback_model(self, model: impl Into<String>) -> Self
pub fn fallback_model(self, model: impl Into<String>) -> Self
Set a fallback model.
Sourcepub fn no_session_persistence(self) -> Self
pub fn no_session_persistence(self) -> Self
Disable session persistence.
Sourcepub fn dangerously_skip_permissions(self) -> Self
pub fn dangerously_skip_permissions(self) -> Self
Bypass all permission checks.
Sourcepub fn agents_json(self, json: impl Into<String>) -> Self
pub fn agents_json(self, json: impl Into<String>) -> Self
Set custom agents as a JSON object.
Sourcepub fn tools(self, tools: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn tools(self, tools: impl IntoIterator<Item = impl Into<String>>) -> Self
Set the list of available built-in tools.
Sourcepub fn include_partial_messages(self) -> Self
pub fn include_partial_messages(self) -> Self
Include partial message chunks as they arrive.
Sourcepub fn input_format(self, format: InputFormat) -> Self
pub fn input_format(self, format: InputFormat) -> Self
Set the input format.
Sourcepub fn strict_mcp_config(self) -> Self
pub fn strict_mcp_config(self) -> Self
Only use MCP servers from --mcp-config.
Sourcepub fn settings(self, settings: impl Into<String>) -> Self
pub fn settings(self, settings: impl Into<String>) -> Self
Path to a settings JSON file or a JSON string.
Sourcepub fn retry(self, policy: RetryPolicy) -> Self
pub fn retry(self, policy: RetryPolicy) -> Self
Set a per-command retry policy.
Sourcepub async fn execute(self) -> Result<QueryResult>
pub async fn execute(self) -> Result<QueryResult>
Execute the query, updating the session’s cumulative cost and turns.