pub struct AgentConfigLoader { /* private fields */ }Expand description
Loads YAML agent definitions, validates them, and produces live Agent instances.
The loader maintains a cache of previously loaded agents so that sub-agent
references can be resolved across files. Tool references are resolved via
the provided ToolRegistry.
Implementations§
Source§impl AgentConfigLoader
impl AgentConfigLoader
Sourcepub fn new(
tool_registry: Arc<dyn ToolRegistry>,
model_factory: Arc<dyn ModelFactory>,
) -> Self
pub fn new( tool_registry: Arc<dyn ToolRegistry>, model_factory: Arc<dyn ModelFactory>, ) -> Self
Create a new loader with the given tool registry and model factory.
Sourcepub async fn load_file(&self, path: &Path) -> Result<Arc<dyn Agent>>
pub async fn load_file(&self, path: &Path) -> Result<Arc<dyn Agent>>
Load a single YAML file, validate it, and produce an Agent.
The agent is cached by name so that subsequent calls to load_file
or load_directory can resolve sub-agent references.
§Errors
Returns a descriptive error if:
- The file cannot be read
- The YAML is malformed or fails schema validation
- A tool reference cannot be resolved from the registry
- A sub-agent reference cannot be resolved from previously loaded agents
Sourcepub async fn load_directory(&self, dir: &Path) -> Result<Vec<Arc<dyn Agent>>>
pub async fn load_directory(&self, dir: &Path) -> Result<Vec<Arc<dyn Agent>>>
Load all .yaml and .yml files from a directory, resolving cross-references.
Files are loaded in two passes:
- Parse all definitions to discover agent names
- Build agents, resolving sub-agent references from the full set
§Errors
Returns a descriptive error if any file fails to parse, validate, or resolve.
Sourcepub async fn reload_file(&self, path: &Path) -> Result<Arc<dyn Agent>>
pub async fn reload_file(&self, path: &Path) -> Result<Arc<dyn Agent>>
Replace a loaded agent by re-reading its YAML file.
Used by the hot reload watcher to update agents when files change.
§Errors
Returns an error if the file cannot be read, parsed, or validated.
Sourcepub async fn get_agent(&self, name: &str) -> Option<Arc<dyn Agent>>
pub async fn get_agent(&self, name: &str) -> Option<Arc<dyn Agent>>
Get a previously loaded agent by name.
Sourcepub async fn all_agents(&self) -> Vec<Arc<dyn Agent>>
pub async fn all_agents(&self) -> Vec<Arc<dyn Agent>>
Get all loaded agents.
Auto Trait Implementations§
impl !RefUnwindSafe for AgentConfigLoader
impl !UnwindSafe for AgentConfigLoader
impl Forget for AgentConfigLoader
impl Freeze for AgentConfigLoaderwhere
*const ArcInner<dyn ToolRegistry> is !null: Freeze,
PhantomData<ArcInner<dyn ToolRegistry>>: Freeze,
*const ArcInner<dyn ModelFactory> is !null: Freeze,
PhantomData<ArcInner<dyn ModelFactory>>: Freeze,
*const ArcInner<RwLock<HashMap<String, Arc<dyn Agent>>>> is !null: Freeze,
PhantomData<ArcInner<RwLock<HashMap<String, Arc<dyn Agent>>>>>: Freeze,
impl Move for AgentConfigLoader
impl Send for AgentConfigLoader
impl Sync for AgentConfigLoader
impl Unpin for AgentConfigLoader
impl UnsafeUnpin for AgentConfigLoaderwhere
*const ArcInner<dyn ToolRegistry> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ToolRegistry>>: UnsafeUnpin,
*const ArcInner<dyn ModelFactory> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ModelFactory>>: UnsafeUnpin,
*const ArcInner<RwLock<HashMap<String, Arc<dyn Agent>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<HashMap<String, Arc<dyn Agent>>>>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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