Skip to main content

AgentKernel

Struct AgentKernel 

Source
pub struct AgentKernel<'a> { /* private fields */ }
Expand description

Headless coordinator for model, tool, policy, session, and observation ports.

Implementations§

Source§

impl<'a> AgentKernel<'a>

Source

pub const fn new( models: &'a dyn ModelRouter, tools: &'a ToolRegistry, policy: &'a PolicyEngine, sessions: &'a dyn SessionStore, clock: &'a dyn KernelClock, ids: &'a dyn KernelIdSource, events: &'a dyn KernelEventSink, ) -> Self

Creates a kernel from replaceable inward-facing ports.

Source

pub const fn with_input_queue(self, queue: &'a KernelInputQueue) -> Self

Attaches a bounded queue consumed only between durable turns.

Source

pub async fn compact( &self, session_id: SessionId, summary: CanonicalMessage, compacted_through_record_id: RecordId, ) -> Result<SessionSnapshot, KernelError>

Appends a manual compaction summary, replacing the compacted prefix in the model-visible transcript with the supplied summary message.

The summary must be an assistant message. compacted_through_record_id must be a record on the active branch. Original records remain in the durable log for audit and replay.

§Errors

Returns an error when the session cannot be loaded, the summary is not an assistant message, the referenced record is not on the active branch, or the append transaction fails.

Source

pub async fn run( &self, session_id: SessionId, config: &KernelRunConfig, cancellation: CancellationScope, ) -> Result<KernelRunOutcome, KernelError>

Runs serial model/tool turns until completion or durable approval pause.

§Errors

Returns a typed failure for invalid durable state, adapter contract violations, rejected events, policy/tool failures, cancellation, or deterministic run limits.

Source

pub async fn resume_approval( &self, session_id: SessionId, resolution: &ApprovalResolution, config: &KernelRunConfig, cancellation: CancellationScope, ) -> Result<KernelRunOutcome, KernelError>

Resolves one persisted approval and continues its original run.

The supplied resolution must contain the exact rich request snapshot stored with the canonical pending approval. Tool arguments and resources are always loaded from durable session state.

§Errors

Returns a typed failure for missing, stale, mismatched, expired, or concurrently resolved approvals and for subsequent runtime failures.

Trait Implementations§

Source§

impl<'a> Debug for AgentKernel<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for AgentKernel<'a>

§

impl<'a> !UnwindSafe for AgentKernel<'a>

§

impl<'a> Freeze for AgentKernel<'a>

§

impl<'a> Send for AgentKernel<'a>

§

impl<'a> Sync for AgentKernel<'a>

§

impl<'a> Unpin for AgentKernel<'a>

§

impl<'a> UnsafeUnpin for AgentKernel<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.