Functions
AgentMemory
Alias of ::ai::memory/AgentMemory
AgentRuntime
Alias of ::runtime/AgentRuntime
ChatOptions
Alias of ::ai::chat/ChatOptions
RetentionPolicy
Alias of ::agent-memory/RetentionPolicy
Session
Alias of ::ai::session/Session
compact-stale-sessions
fn (rt: ::ai::agent::runtime/AgentRuntime, handler: Fn): Vec
Run an app-provided compaction handler for all registered sessions.
job-error
fn (rt: ::ai::agent::runtime/AgentRuntime, session: ::ai::session/Session, action: Str, error: Any): LifecycleJob
Build a failed LifecycleJob result and record it in the runtime error log.
job-ok
fn (session: ::ai::session/Session, action: Str, result: Any?): LifecycleJob
Build a successful LifecycleJob result.
ns
Alias of ::ai::agent::lifecycle/
Reusable scheduled lifecycle helpers for AI agents.
These functions keep scheduling mechanics and error handling generic while concrete agents provide memory construction, authorization, and compaction policy.
prune-raw-memory
fn (mem: ::ai::memory/AgentMemory, policy: ::ai::agent::memory/RetentionPolicy): Int
Prune raw session memory older than policy.raw-retention-secs; returns deleted count.
prune-sessions
fn (rt: ::ai::agent::runtime/AgentRuntime, policy: ::ai::agent::memory/RetentionPolicy, memory-for-session: Fn): Vec
Run an app-provided memory factory and prune handler for all registered sessions.
run-session-job
fn (rt: ::ai::agent::runtime/AgentRuntime, action: Str, handler: Fn): Vec
Run handler(session) for every registered session and collect a
LifecycleJob per session.
Per-session recovery is handled inside the callback with if-err:
if a handler halts via fail() / cancel(), the structured error
is captured and recorded on rt.errors-store, and the slot becomes
LifecycleJob.ok = false. The loop always processes every session
and always returns a uniform Vec<LifecycleJob> — halts never
escape run-session-job.
schedule-descriptor
fn (name: Str, cron: Str, action: Str): Map
Return a neutral descriptor agents can attach to scheduled lifecycle functions.
Types
LifecycleJob
LifecycleJob type {
session-id: Str,
action: Str,
ok: Bool,
result: Any?,
error: Str?
}
Result record from a lifecycle job applied to one session.