pub struct AgentKernel<'a> { /* private fields */ }Expand description
Headless coordinator for model, tool, policy, session, and observation ports.
Implementations§
Source§impl<'a> AgentKernel<'a>
impl<'a> AgentKernel<'a>
Sourcepub 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
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.
Sourcepub const fn with_input_queue(self, queue: &'a KernelInputQueue) -> Self
pub const fn with_input_queue(self, queue: &'a KernelInputQueue) -> Self
Attaches a bounded queue consumed only between durable turns.
Sourcepub async fn compact(
&self,
session_id: SessionId,
summary: CanonicalMessage,
compacted_through_record_id: RecordId,
) -> Result<SessionSnapshot, KernelError>
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.
Sourcepub async fn run(
&self,
session_id: SessionId,
config: &KernelRunConfig,
cancellation: CancellationScope,
) -> Result<KernelRunOutcome, KernelError>
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.
Sourcepub async fn resume_approval(
&self,
session_id: SessionId,
resolution: &ApprovalResolution,
config: &KernelRunConfig,
cancellation: CancellationScope,
) -> Result<KernelRunOutcome, KernelError>
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.