pub struct RunSession<TCtx> { /* private fields */ }Expand description
Manages the run session for an agent.
It initializes all necessary components for the agent to run
and handles the execution of the agent’s tasks.
Once finished, the session cleans up any resources used during the run.
The session can be reused in multiple runs. RunSession binds to a specific
context value that is used to resolve instructions and invoke tools, while input items remain per run and are supplied to each invocation.
Implementations§
Source§impl<TCtx> RunSession<TCtx>
impl<TCtx> RunSession<TCtx>
Sourcepub async fn new(
params: Arc<AgentParams<TCtx>>,
context: TCtx,
) -> Result<Self, AgentError>
pub async fn new( params: Arc<AgentParams<TCtx>>, context: TCtx, ) -> Result<Self, AgentError>
Creates a new run session and initializes dependencies
Sourcepub async fn run(
&self,
request: RunSessionRequest,
) -> Result<AgentResponse, AgentError>
pub async fn run( &self, request: RunSessionRequest, ) -> Result<AgentResponse, AgentError>
Run a non-streaming execution of the agent.
Sourcepub fn run_stream(
&self,
request: RunSessionRequest,
) -> Result<AgentStream, AgentError>
pub fn run_stream( &self, request: RunSessionRequest, ) -> Result<AgentStream, AgentError>
Run a streaming execution of the agent.
pub async fn close(self) -> Result<(), AgentError>
Auto Trait Implementations§
impl<TCtx> !RefUnwindSafe for RunSession<TCtx>
impl<TCtx> !UnwindSafe for RunSession<TCtx>
impl<TCtx> Freeze for RunSession<TCtx>
impl<TCtx> Send for RunSession<TCtx>
impl<TCtx> Sync for RunSession<TCtx>
impl<TCtx> Unpin for RunSession<TCtx>
impl<TCtx> UnsafeUnpin for RunSession<TCtx>where
Arc<AgentParams<TCtx>>: UnsafeUnpin,
Arc<TCtx>: UnsafeUnpin,
Arc<Vec<Box<dyn ToolkitSession<TCtx> + Sync + Send>>>: UnsafeUnpin,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more