pub struct RuntimeBuilder { /* private fields */ }Expand description
Builder for constructing a Runtime with the desired configuration.
Implementations§
Source§impl RuntimeBuilder
impl RuntimeBuilder
Sourcepub fn from_file(path: &str) -> Result<Self, KernexError>
pub fn from_file(path: &str) -> Result<Self, KernexError>
Create a new builder pre-populated from a declarative agent definition file.
The file format is detected by extension: .yaml / .yml use YAML
(requires the yaml feature on kernex-core); all other extensions
use TOML. Missing files silently fall back to defaults.
Maps [runtime] fields (data_dir, system_prompt, channel,
project) and [memory] → db_path into the builder. Provider
selection is left to the caller.
§Example (agent.toml)
[runtime]
name = "my-agent"
data_dir = "~/.my-agent"
channel = "api"
project = "acme"
system_prompt = "You are a helpful coding assistant."
[memory]
db_path = "~/.my-agent/memory.db"Sourcepub fn from_config(config: &KernexConfig) -> Self
pub fn from_config(config: &KernexConfig) -> Self
Populate a builder from a pre-parsed KernexConfig.
Maps runtime.{data_dir, system_prompt, channel, project} and
memory.db_path into builder fields. Provider selection is left
to the caller.
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Create a new builder configured from environment variables.
Recognizes:
KERNEX_DATA_DIRKERNEX_DB_PATH(whensqlite-storefeature is enabled)KERNEX_SYSTEM_PROMPTKERNEX_CHANNELKERNEX_PROJECT
Sourcepub fn db_path(self, path: &str) -> Self
pub fn db_path(self, path: &str) -> Self
Set a custom database path (default: {data_dir}/memory.db).
Sourcepub fn system_prompt(self, prompt: &str) -> Self
pub fn system_prompt(self, prompt: &str) -> Self
Set the base system prompt.
Sourcepub fn hook_runner(self, runner: Arc<dyn HookRunner>) -> Self
pub fn hook_runner(self, runner: Arc<dyn HookRunner>) -> Self
Set a hook runner for tool lifecycle events.
Sourcepub fn permission_rules(self, rules: PermissionRules) -> Self
pub fn permission_rules(self, rules: PermissionRules) -> Self
Set declarative allow/deny permission rules for tool calls.
Sourcepub fn guardrail_runner(self, runner: Arc<dyn GuardrailRunner>) -> Self
pub fn guardrail_runner(self, runner: Arc<dyn GuardrailRunner>) -> Self
Set a guardrail runner that intercepts and filters input/output text.
Sourcepub fn auto_compact(self, enable: bool) -> Self
pub fn auto_compact(self, enable: bool) -> Self
Enable automatic context compaction on long conversations.
When enabled, every call into the runtime that builds context (e.g.
Runtime::complete, Runtime::complete_stream, Runtime::run)
will, on overflow past max_context_messages, summarize the dropped
rows via the active provider and prepend the summary to the system
prompt under [Earlier conversation summary]. The summarization
adds one extra provider round-trip per overflow event (not per turn),
uses a fixed instruction prompt that never reveals the agent’s own
system prompt, and falls back to the default Drop behavior if the
provider call fails.
Default is off to preserve v0.4.0 behavior. Recommended for any long-running interactive session; the default exists only so existing callers do not silently change billing characteristics.
Sourcepub async fn build(self) -> Result<Runtime, KernexError>
pub async fn build(self) -> Result<Runtime, KernexError>
Build and initialize the runtime.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RuntimeBuilder
impl !UnwindSafe for RuntimeBuilder
impl Freeze for RuntimeBuilder
impl Send for RuntimeBuilder
impl Sync for RuntimeBuilder
impl Unpin for RuntimeBuilder
impl UnsafeUnpin for RuntimeBuilder
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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