pub struct AgentKernel { /* private fields */ }Expand description
The stateless Agent Kernel — a single-turn ReAct executor.
Cheap to create, safe to clone, safe to share across threads. Does not own transcript, session, or any cross-turn state.
Implementations§
Source§impl AgentKernel
impl AgentKernel
Sourcepub fn builder() -> AgentKernelBuilder
pub fn builder() -> AgentKernelBuilder
Create a new builder for AgentKernel.
Sourcepub fn llm(&self) -> &Arc<dyn ChatProvider> ⓘ
pub fn llm(&self) -> &Arc<dyn ChatProvider> ⓘ
Access the LLM provider.
Sourcepub fn set_llm(&mut self, llm: Arc<dyn ChatProvider>)
pub fn set_llm(&mut self, llm: Arc<dyn ChatProvider>)
Hot-swap the LLM provider.
Replaces the provider used for subsequent completions. Used by the
TUI /model picker to switch models without restarting the process.
Safe to call between turns; callers must not invoke it while a turn
is in flight on the same kernel (the runtime’s turn task owns the
kernel via &mut self for the duration of the turn).
Sourcepub fn tools(&self) -> &ToolRegistry
pub fn tools(&self) -> &ToolRegistry
Access the tool registry.
Sourcepub fn tools_mut(&mut self) -> &mut ToolRegistry
pub fn tools_mut(&mut self) -> &mut ToolRegistry
Mutable access to the tool registry.
Used by [AgentRuntime::enable_checkpoints] to register
session-scoped read-only tools (checkpoint_list,
checkpoint_diff) once the session id is known.
Sourcepub fn shutdown_token(&self) -> Option<&CancellationToken>
pub fn shutdown_token(&self) -> Option<&CancellationToken>
Access the cancellation token, if one was configured.
Useful for tests verifying that token propagation through
with_tools (and other clones) preserves the handle.
Sourcepub fn storage(&self) -> &Arc<dyn StorageBackend> ⓘ
pub fn storage(&self) -> &Arc<dyn StorageBackend> ⓘ
Access the storage backend.
Sourcepub fn session_store(&self) -> &Arc<dyn SessionStore> ⓘ
pub fn session_store(&self) -> &Arc<dyn SessionStore> ⓘ
Access the session store.
Sourcepub fn hooks(&self) -> &HookRegistry
pub fn hooks(&self) -> &HookRegistry
Public access to the hook registry. Used by AgentRuntime to
dispatch cross-turn PreCompact / PostCompact events that are
not handled by RunCore.
Sourcepub fn with_tools(&self, tools: ToolRegistry) -> Self
pub fn with_tools(&self, tools: ToolRegistry) -> Self
Create a new kernel with a different tool registry (same LLM, same config). Useful for Multi-Agent scenarios where sub-agents get restricted tool subsets.
Sourcepub async fn run(&self, ctx: TurnContext) -> Result<TurnOutcome>
pub async fn run(&self, ctx: TurnContext) -> Result<TurnOutcome>
Execute one turn of the ReAct loop.
Takes a TurnContext prepared by the Wrapper and returns a
TurnOutcome containing only the new messages produced during
this turn, plus usage stats and finish reason.
The Kernel is stateless: it does not retain any state between calls. All cross-turn concerns (transcript accumulation, compaction, persistence) are the Wrapper’s responsibility.