Skip to main content

AgentRuntime

Struct AgentRuntime 

Source
pub struct AgentRuntime {
    pub state: AgentSessionState,
    /* private fields */
}
Expand description

Orchestrates a single agent turn: manages steering, lifecycle events, and the LLM call.

Fields§

§state: AgentSessionState

Mutable session state including conversation history and statistics.

Implementations§

Source§

impl AgentRuntime

Source

pub fn new( state: AgentSessionState, event_sink: Option<EventSink>, steering_receiver: Option<UnboundedReceiver<SteeringMessage>>, ) -> Self

Create a new runtime with the given session state, optional event sink, and steering receiver.

Source

pub fn set_event_handler(&mut self, sink: Option<EventSink>)

Replace the structured event sink used for lifecycle event emission.

Source

pub fn set_steering_receiver( &mut self, receiver: Option<UnboundedReceiver<SteeringMessage>>, )

Replace the steering message receiver channel for this runtime.

Source

pub fn take_steering_receiver( &mut self, ) -> Option<UnboundedReceiver<SteeringMessage>>

Take ownership of the steering receiver, leaving None in its place.

Source

pub fn split_mut(&mut self) -> (&mut AgentSessionState, &mut RuntimeSteering)

Borrow the session state and steering controller mutably at the same time.

Source

pub fn has_pending_follow_up_inputs(&self) -> bool

Returns true if there are queued follow-up user inputs waiting to be consumed.

Source

pub fn run_until_idle(&mut self) -> Option<String>

Pop the next queued follow-up input, add a tagged user message, and retain the intent until the enclosing history checkpoint succeeds.

Source

pub fn queue_follow_up_input(&mut self, input: String)

Queue a follow-up input to be consumed by run_until_idle on the next iteration, causing the session loop to start a new turn with this input without waiting for the user to type anything.

Source

pub fn try_queue_follow_up_input( &mut self, input: String, ) -> Result<(), FollowUpQueueFull>

Queue a follow-up input while exposing FIFO overflow to the caller.

Source

pub fn try_queue_synthetic_follow_up_input( &mut self, input: String, ) -> Result<(), FollowUpQueueFull>

Queue a harness-generated continuation or recovery instruction.

Source

pub fn admit_follow_up_steer( &mut self, steer: FollowUpSteer, ) -> Option<QueuedFollowUpIntent>

Authoritatively admit a live steer, resolving its receipt with exactly one terminal outcome. See RuntimeSteering::admit_follow_up_steer.

Source

pub fn drain_rejected_steers(&mut self)

Reject steers left in the channel after admission closed. Called before Self::open_admission so a late arrival cannot leak into the next turn.

Source

pub fn open_admission(&mut self)

Reopen live-steer admission for a new turn.

Source

pub fn close_admission(&mut self)

Close live-steer admission atomically with the final steering drain.

Source

pub const fn admission_closed(&self) -> bool

Source

pub fn set_cancellation_precedence(&mut self, value: bool)

Declare that cancellation outranks pending steers for this turn.

Source

pub fn restore_follow_up_state( &mut self, pending_intents: impl IntoIterator<Item = QueuedFollowUpIntent>, applied_intent_ids: impl IntoIterator<Item = String>, ) -> Result<(), FollowUpQueueFull>

Restore the durable steering snapshot after loading session history. Pending intents already represented by a tagged user message, or already in the applied-ID window, are skipped; identical text with a different ID is intentionally retained.

Source

pub fn applied_follow_up_intent_ids(&self) -> &VecDeque<String>

Access the intent IDs acknowledged by this runtime for checkpointing.

Source

pub fn clear_pending_follow_up_inputs(&mut self)

Drop follow-up inputs belonging to the discarded execution context.

Source

pub async fn poll_turn_control(&mut self) -> RuntimeControl

Poll the steering channel for control signals during the current turn.

Source

pub async fn poll_tool_control(&mut self) -> RuntimeControl

Poll the steering channel for control signals during tool execution.

Source

pub fn take_emitted_events(&mut self) -> Vec<ThreadEvent>

Take all emitted lifecycle events, leaving the internal buffer empty.

Source

pub fn tool_call_item_id(&self, call_id: &str) -> Option<String>

Look up the lifecycle item ID for a given tool call identifier.

Source

pub fn complete_tool_call( &mut self, call_id: &str, status: ToolCallStatus, outcome: Option<ToolOutcome>, )

Mark a specific tool call as completed with the given status and emit lifecycle events.

Source

pub fn complete_open_tool_calls(&mut self, status: ToolCallStatus)

Mark all still-open tool calls as completed with the given status and emit lifecycle events.

Source

pub async fn run_turn_once( &mut self, provider: &mut Box<dyn LLMProvider>, request: LLMRequest, timeout: Option<Duration>, ) -> Result<TurnExecution>

Execute a single LLM turn: stream the response, update session state, and return the result.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> PtyHandle for T
where T: Send,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

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