Skip to main content

SidAgent

Struct SidAgent 

Source
pub struct SidAgent { /* private fields */ }
Expand description

Top-level agent combining chat configuration, tool bindings, and sandbox policy.

Implementations§

Source§

impl SidAgent

Source

pub fn new(config: ChatConfig, workspace_root: Path<'static>) -> Self

Create a new agent with default settings rooted at workspace_root.

The workspace root is used as both the configuration root and the filesystem root. No rc.conf files are loaded; the agent operates with the supplied ChatConfig only.

Source

pub fn from_workspace( root: &Path<'_>, fallback: ChatConfig, ) -> Result<Self, SError>

Load the default agent from a workspace’s configuration files.

When no configuration exists at root, the fallback chat config is used with default settings.

§Errors

Returns an error when the configuration exists but is malformed, or when the default agent cannot be resolved.

Source

pub fn from_workspace_with_config_root( workspace_root: &Path<'_>, config_root: &Path<'_>, fallback: ChatConfig, ) -> Result<Self, SError>

Load the default agent using separate workspace and configuration roots.

The config_root is the directory containing agents.conf and tools.conf, while workspace_root is the directory exposed to tool invocations and sandbox policies.

§Errors

Returns an error when the configuration exists but is malformed, or when the default agent cannot be resolved.

Source

pub fn from_workspace_agent( root: &Path<'_>, agent: &str, fallback: ChatConfig, ) -> Result<Self, SError>

Load a named agent from a workspace’s configuration files.

§Errors

Returns an error when the agent does not exist in the configuration or is disabled.

Source

pub fn from_workspace_agent_with_config_root( workspace_root: &Path<'_>, config_root: &Path<'_>, agent: &str, fallback: ChatConfig, ) -> Result<Self, SError>

Load a named agent using separate workspace and configuration roots.

§Errors

Returns an error when the agent does not exist in the configuration or is disabled.

Source

pub fn from_workspace_compactor_with_config_root( workspace_root: &Path<'_>, config_root: &Path<'_>, fallback: ChatConfig, ) -> Result<Self, SError>

Load the compaction agent using separate workspace and configuration roots.

If a compact agent is declared in the configuration it is used; otherwise a default compactor is built from fallback with the built-in compaction system prompt. The returned agent exposes memory-only tools.

§Errors

Returns an error when the configuration exists but is malformed.

Source

pub fn from_config( config: &Config, agent: &str, filesystem: Path<'static>, ) -> Result<Self, SError>

Build an agent directly from a pre-loaded Config.

§Errors

Returns an error when the agent does not exist in the configuration or is disabled.

Source

pub fn id(&self) -> &str

Return the agent’s identifier.

Source

pub fn requires_confirmation(&self) -> bool

Return true when the agent’s enablement switch is SwitchPosition::Manual.

Source

pub fn with_session(self, session: Arc<SidSession>) -> Self

Attach a session to this agent, making the session root writable.

Source

pub fn with_memory_source( self, memory_source: Option<CompactionProvenance>, ) -> Self

Override the compaction provenance used for ask-an-expert memory chains.

Source

pub fn compaction_snapshot(&self) -> CompactionExpertConfig

Snapshot the agent’s identity and model for use as a compaction expert.

Source

pub async fn bash_with_renderer( &self, command: &str, restart: bool, renderer: &mut dyn Renderer, ) -> Result<String, Error>

Execute a bash command in the agent’s PTY session, streaming output to renderer.

When restart is true the existing PTY is torn down and a fresh session is started before executing command.

§Errors

Returns an I/O error when the PTY cannot be created or the command fails to execute.

Trait Implementations§

Source§

impl Agent for SidAgent

Source§

fn stream_label(&self) -> String

Returns a display label for streaming output.
Source§

fn take_turn<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, messages: &'life2 mut Vec<MessageParam>, budget: &'life3 Arc<Budget>, ) -> Pin<Box<dyn Future<Output = Result<TurnOutcome, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Takes a conversation turn, potentially making multiple API calls.
Source§

fn take_turn_streaming<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, messages: &'life2 mut Vec<MessageParam>, budget: &'life3 Arc<Budget>, renderer: &'life4 mut dyn Renderer, context: AgentStreamContext, ) -> Pin<Box<dyn Future<Output = Result<TurnOutcome, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Takes a conversation turn, streaming output to the renderer.
Source§

fn max_tokens<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = u32> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the maximum number of tokens for responses.
Source§

fn model<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Model> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the model to use for this agent.
Source§

fn metadata<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<Metadata>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns optional metadata for requests.
Source§

fn stop_sequences<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns optional stop sequences to halt generation.
Source§

fn system<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<SystemPrompt>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the system prompt for the agent.
Source§

fn caching_enabled(&self) -> bool

Returns whether prompt caching is enabled.
Source§

fn temperature<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<f32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the temperature for response generation.
Source§

fn thinking<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<ThinkingConfig>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the thinking configuration for the agent.
Source§

fn tool_choice<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<ToolChoice>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the tool choice configuration.
Source§

fn tools<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<Arc<dyn Tool<Self>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the tools available to this agent.
Source§

fn top_k<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the top-k sampling parameter.
Source§

fn top_p<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<f32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the top-p (nucleus) sampling parameter.
Source§

fn filesystem<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<&dyn FileSystem>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the filesystem implementation for this agent.
Source§

fn hook_message<'life0, 'life1, 'async_trait>( &'life0 self, resp: &'life1 Message, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Hook called after receiving a message response.
Source§

fn hook_message_create_params<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 MessageCreateParams, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Hook called before sending a message create request.
Source§

fn text_editor<'life0, 'async_trait>( &'life0 self, tool_use: ToolUseBlock, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handles text editor tool use.
Source§

fn bash<'life0, 'life1, 'async_trait>( &'life0 self, command: &'life1 str, restart: bool, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Executes a bash command.
Source§

fn handle_tool_use<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, resp: &'life2 Message, ) -> Pin<Box<dyn Future<Output = ControlFlow<Result<StopReason, Error>, Vec<ContentBlock>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Handles tool use requests from the model.
Source§

fn handle_tool_use_streaming<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, resp: &'life2 Message, renderer: &'life3 mut dyn Renderer, context: &'life4 AgentStreamContext, ) -> Pin<Box<dyn Future<Output = ControlFlow<Result<StopReason, Error>, Vec<ContentBlock>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Handles tool use requests from the model with streaming output.
Source§

fn handle_max_tokens<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<StopReason, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Handles the case when max tokens is reached.
Source§

fn handle_end_turn<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<StopReason, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Handles the end of a conversation turn.
Source§

fn handle_stop_sequence<'life0, 'async_trait>( &'life0 self, sequence: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<StopReason, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Handles when a stop sequence is encountered.
Source§

fn handle_refusal<'life0, 'async_trait>( &'life0 self, resp: Message, ) -> Pin<Box<dyn Future<Output = Result<StopReason, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Handles when the model refuses to respond.
Source§

fn take_turn_streaming_root<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, messages: &'life2 mut Vec<MessageParam>, budget: &'life3 Arc<Budget>, renderer: &'life4 mut dyn Renderer, ) -> Pin<Box<dyn Future<Output = Result<TurnOutcome, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait,

Takes a conversation turn, streaming output with a root context label.
Source§

fn take_default_turn<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, messages: &'life2 mut Vec<MessageParam>, budget: &'life3 Arc<Budget>, ) -> Pin<Box<dyn Future<Output = Result<TurnOutcome, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Default implementation for taking a conversation turn.
Source§

fn take_default_turn_streaming<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, messages: &'life2 mut Vec<MessageParam>, budget: &'life3 Arc<Budget>, renderer: &'life4 mut dyn Renderer, context: AgentStreamContext, ) -> Pin<Box<dyn Future<Output = Result<TurnOutcome, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait,

Default implementation for taking a conversation turn with streaming output.
Source§

fn step_turn<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, messages: &'life2 mut Vec<MessageParam>, tokens_rem: &'life3 mut BudgetAllocation<'_>, ) -> Pin<Box<dyn Future<Output = ControlFlow<Result<TurnOutcome, Error>, TurnStep>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Executes a single step in a conversation turn.
Source§

fn step_turn_streaming<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, messages: &'life2 mut Vec<MessageParam>, tokens_rem: &'life3 mut BudgetAllocation<'_>, renderer: &'life4 mut dyn Renderer, context: &'life5 AgentStreamContext, ) -> Pin<Box<dyn Future<Output = ControlFlow<Result<TurnOutcome, Error>, TurnStep>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, Self: 'async_trait,

Executes a single step in a conversation turn with streaming output.
Source§

fn step_default_turn<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, messages: &'life2 mut Vec<MessageParam>, tokens_rem: &'life3 mut BudgetAllocation<'_>, ) -> Pin<Box<dyn Future<Output = ControlFlow<Result<TurnOutcome, Error>, TurnStep>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Default implementation for executing a single step in a conversation turn.
Source§

fn step_default_turn_streaming<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, messages: &'life2 mut Vec<MessageParam>, tokens_rem: &'life3 mut BudgetAllocation<'_>, renderer: &'life4 mut dyn Renderer, context: &'life5 AgentStreamContext, ) -> Pin<Box<dyn Future<Output = ControlFlow<Result<TurnOutcome, Error>, TurnStep>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, Self: 'async_trait,

Default implementation for executing a single step with streaming output.
Source§

fn handle_default_tool_use<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, resp: &'life2 Message, ) -> Pin<Box<dyn Future<Output = ControlFlow<Result<StopReason, Error>, Vec<ContentBlock>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Default implementation for handling tool use requests.
Source§

fn handle_default_tool_use_streaming<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, client: &'life1 Anthropic, resp: &'life2 Message, renderer: &'life3 mut dyn Renderer, context: &'life4 AgentStreamContext, ) -> Pin<Box<dyn Future<Output = ControlFlow<Result<StopReason, Error>, Vec<ContentBlock>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait,

Default implementation for handling tool use requests with streaming output.
Source§

fn collect_tool_uses<'life0, 'life1, 'async_trait>( &'life0 self, resp: &'life1 Message, ) -> Pin<Box<dyn Future<Output = Vec<(ToolUseBlock, Arc<dyn Tool<Self>>)>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Collect all ToolUseBlock blocks from the message.
Source§

fn create_request<'life0, 'async_trait>( &'life0 self, max_tokens: u32, messages: Vec<MessageParam>, stream: bool, ) -> Pin<Box<dyn Future<Output = MessageCreateParams> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Creates a message request with the agent’s configuration.
Source§

fn search<'life0, 'life1, 'async_trait>( &'life0 self, search: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Searches the filesystem for files matching the query.
Source§

fn view<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, view_range: Option<(u32, u32)>, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Views the contents of a file.
Source§

fn str_replace<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, path: &'life1 str, old_str: &'life2 str, new_str: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Replaces text in a file.
Source§

fn insert<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 str, insert_line: u32, insert_text: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Inserts text at a specific line in a file.
Source§

fn create<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 str, file_text: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Create a file or error if it exists. Read more
Source§

impl ChatAgent for SidAgent

Source§

fn config(&self) -> &ChatConfig

Returns the active chat configuration.
Source§

fn config_mut(&mut self) -> &mut ChatConfig

Returns the active chat configuration for mutation.

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