pub struct AgentRuntime<P, S = Idle>where
P: ChatProvider,{ /* private fields */ }Expand description
Thin wrapper around session and env actors.
AgentRuntime owns no mutable data — all persistent state lives in
background actors:
EnvActor— ownsFuneraEnv(model, client, tool/skill registries, sandbox policy), theFuneraEnvWatcher(watch-based hot-reload),ToolBus+ToolExecutor, audit bus, and env state broadcast channel.SessionActor— ownsVec<FuneraMessage>.
The generic parameter S is a type-state marker — Idle means
no send/send_stream is in progress, Acquired means one is active.
Send operations consume AgentRuntime<P, Idle> and return a handle that
eventually yields back AgentRuntime<P, Idle>.
§Mutation
All env mutations (e.g., set_model,
add_tool) send an EnvCmd
to the actor, which atomically updates the internal state, pushes to the
watch channel (picked up by the ReAct loop on the next iteration), and
broadcasts an EnvStateEvent.
§Hot-Reload
The ReAct loop calls get_react_config once per
fire/send call to obtain a ReActConfig
bundle containing the [FuneraEnvWatcher]. Every iteration, the watcher
snapshots the latest model, client, tools, and skills from the watch
channels — enabling zero-coordination runtime changes.
Implementations§
Source§impl<P, S> AgentRuntime<P, S>where
P: ChatProvider,
impl<P, S> AgentRuntime<P, S>where
P: ChatProvider,
Sourcepub fn builder() -> AgentRuntimeBuilder
pub fn builder() -> AgentRuntimeBuilder
Create a new builder.
Sourcepub fn session_tx(&self) -> UnboundedSender<SessionCmd>
pub fn session_tx(&self) -> UnboundedSender<SessionCmd>
Access the session control channel.
Sourcepub async fn subscribe_env_state(&self) -> Receiver<EnvStateEvent>
pub async fn subscribe_env_state(&self) -> Receiver<EnvStateEvent>
Subscribe to runtime-level environment state events.
Sourcepub async fn tool_names(&self) -> Vec<String>
pub async fn tool_names(&self) -> Vec<String>
List registered tool names from the env actor.
Sourcepub fn set_model(&self, model: impl Into<String>)
pub fn set_model(&self, model: impl Into<String>)
Change the LLM model name at runtime.
Pushes to the internal watch channel (picked up by the ReAct loop on
the next iteration) and broadcasts EnvStateEvent::LlmChanged.
Sourcepub fn set_client(&self, client: Client<OpenAIConfig>)
pub fn set_client(&self, client: Client<OpenAIConfig>)
Change the LLM client at runtime (endpoint, key, etc.).
Sourcepub fn remove_tool(&self, name: impl Into<String>)
pub fn remove_tool(&self, name: impl Into<String>)
Remove a tool by name at runtime.
Sourcepub fn set_tool_availability(&self, name: impl Into<String>, available: bool)
pub fn set_tool_availability(&self, name: impl Into<String>, available: bool)
Set tool availability (enabled/disabled) at runtime.