Skip to main content

spawn_runtime

Function spawn_runtime 

Source
pub async fn spawn_runtime() -> Result<Runtime, RuntimeError>
Expand description

Build the runtime a subagent runs on. Preferred: EngineHost::worker_runtime() — shares the host credential source and token cache (so NO set_global_broker re-install and NO token-cache eviction per spawn) and takes a clone of the cached worker registry template. Legacy path (no host installed, or kill-switch set): today’s Runtime::new() + rebuilt tools + apply_auth_config, verbatim.

Called from the subagent’s own OS thread / current-thread tokio runtime: EngineHost::current() is a OnceLock read and worker_runtime() only touches tokio::sync primitives, so this is runtime-agnostic.