pub struct AgentSession { /* private fields */ }Expand description
Workspace-bound session. All LLM and tool operations happen here.
History is automatically accumulated after each send() call.
Use history() to retrieve the current conversation log.
Implementations§
Source§impl AgentSession
impl AgentSession
Sourcepub async fn send(
&self,
prompt: &str,
history: Option<&[Message]>,
) -> Result<AgentResult>
pub async fn send( &self, prompt: &str, history: Option<&[Message]>, ) -> Result<AgentResult>
Send a prompt and wait for the complete response.
When history is None, uses (and auto-updates) the session’s
internal conversation history. When Some, uses the provided
history instead (the internal history is not modified).
Sourcepub async fn stream(
&self,
prompt: &str,
history: Option<&[Message]>,
) -> Result<(Receiver<AgentEvent>, JoinHandle<()>)>
pub async fn stream( &self, prompt: &str, history: Option<&[Message]>, ) -> Result<(Receiver<AgentEvent>, JoinHandle<()>)>
Send a prompt and stream events back.
When history is None, uses the session’s internal history
(note: streaming does not auto-update internal history since
the result is consumed asynchronously via the channel).
When Some, uses the provided history instead.
Sourcepub async fn bash(&self, command: &str) -> Result<String>
pub async fn bash(&self, command: &str) -> Result<String>
Execute a bash command in the workspace.
Sourcepub async fn glob(&self, pattern: &str) -> Result<Vec<String>>
pub async fn glob(&self, pattern: &str) -> Result<Vec<String>>
Search for files matching a glob pattern.
Sourcepub async fn grep(&self, pattern: &str) -> Result<String>
pub async fn grep(&self, pattern: &str) -> Result<String>
Search file contents with a regex pattern.
Sourcepub async fn tool(&self, name: &str, args: Value) -> Result<ToolCallResult>
pub async fn tool(&self, name: &str, args: Value) -> Result<ToolCallResult>
Execute a tool by name, bypassing the LLM.
Sourcepub async fn set_lane_handler(
&self,
lane: SessionLane,
config: LaneHandlerConfig,
)
pub async fn set_lane_handler( &self, lane: SessionLane, config: LaneHandlerConfig, )
Configure a lane’s handler mode (Internal/External/Hybrid).
Only effective when a queue is configured via SessionOptions::with_queue_config.
Sourcepub async fn complete_external_task(
&self,
task_id: &str,
result: ExternalTaskResult,
) -> bool
pub async fn complete_external_task( &self, task_id: &str, result: ExternalTaskResult, ) -> bool
Complete an external task by ID.
Returns true if the task was found and completed, false if not found.
Sourcepub async fn pending_external_tasks(&self) -> Vec<ExternalTask>
pub async fn pending_external_tasks(&self) -> Vec<ExternalTask>
Get pending external tasks awaiting completion by an external handler.
Sourcepub async fn queue_stats(&self) -> SessionQueueStats
pub async fn queue_stats(&self) -> SessionQueueStats
Get queue statistics (pending, active, external counts per lane).
Sourcepub async fn queue_metrics(&self) -> Option<MetricsSnapshot>
pub async fn queue_metrics(&self) -> Option<MetricsSnapshot>
Get a metrics snapshot from the queue (if metrics are enabled).
Sourcepub async fn dead_letters(&self) -> Vec<DeadLetter>
pub async fn dead_letters(&self) -> Vec<DeadLetter>
Get dead letters from the queue’s DLQ (if DLQ is enabled).