walrus_core/agent/builder.rs
1//! Fluent builder for constructing an [`Agent`].
2
3use crate::agent::Agent;
4use crate::agent::config::AgentConfig;
5use crate::model::Model;
6
7/// Fluent builder for [`Agent<M>`].
8///
9/// Requires a model at construction. Use [`AgentConfig`] builder methods
10/// for field configuration, then pass it via [`AgentBuilder::config`].
11pub struct AgentBuilder<M: Model> {
12 config: AgentConfig,
13 model: M,
14}
15
16impl<M: Model> AgentBuilder<M> {
17 /// Create a new builder with the given model.
18 pub fn new(model: M) -> Self {
19 Self {
20 config: AgentConfig::default(),
21 model,
22 }
23 }
24
25 /// Set the full config, replacing all fields.
26 ///
27 /// Typical usage: build an `AgentConfig` via its fluent methods,
28 /// then pass it here before calling `build()`.
29 pub fn config(mut self, config: AgentConfig) -> Self {
30 self.config = config;
31 self
32 }
33
34 /// Build the [`Agent`].
35 pub fn build(self) -> Agent<M> {
36 Agent {
37 config: self.config,
38 model: self.model,
39 history: Vec::new(),
40 }
41 }
42}