pub struct AgentBuilder<'a> { /* private fields */ }Expand description
Builder for creating an Agent on an AgyBridge.
Obtained from AgyBridge::agent(). Implements IntoFuture so you can
.await it directly, or chain optional .tools() /
.hooks() calls before awaiting.
Implementations§
Source§impl AgentBuilder<'_>
impl AgentBuilder<'_>
Sourcepub fn tools(self, registry: ToolRegistry) -> Self
pub fn tools(self, registry: ToolRegistry) -> Self
Attach a ToolRegistry containing custom
Rust tools for the agent.
The registry’s tool definitions are automatically merged into the agent configuration.
§Errors (at build time)
Returns error::Error::InvalidConfig if config.tools is
already non-empty — pass tools via the registry or via
config.tools, not both.
Sourcepub fn hooks(self, hooks: Hooks) -> Self
pub fn hooks(self, hooks: Hooks) -> Self
Attach Hooks for lifecycle event
callbacks (pre/post turn, tool-call gating, etc.).
Sourcepub fn policy_handler(self, handler: impl AskUserHandler + 'static) -> Self
pub fn policy_handler(self, handler: impl AskUserHandler + 'static) -> Self
Attach a custom AskUserHandler to manage interactive tool-call confirmations.
Sourcepub fn conversation_id(self, id: impl Into<String>) -> Self
pub fn conversation_id(self, id: impl Into<String>) -> Self
Set a pre-existing conversation ID to resume.
Sourcepub fn model(self, model: impl Into<String>) -> Self
pub fn model(self, model: impl Into<String>) -> Self
Set the model backend (e.g. "gemini-3.5-flash").
Sourcepub fn system_instructions(
self,
instructions: impl Into<SystemInstructions>,
) -> Self
pub fn system_instructions( self, instructions: impl Into<SystemInstructions>, ) -> Self
Set system instructions for the agent.
Sourcepub fn workspaces(
self,
workspaces: impl IntoIterator<Item = impl Into<PathBuf>>,
) -> Self
pub fn workspaces( self, workspaces: impl IntoIterator<Item = impl Into<PathBuf>>, ) -> Self
Append workspace directories the agent is allowed to access and modify.
Sourcepub fn policies(
self,
policies: impl IntoIterator<Item = impl Into<PolicyRule>>,
) -> Self
pub fn policies( self, policies: impl IntoIterator<Item = impl Into<PolicyRule>>, ) -> Self
Append policy rules to govern tool execution.
Sourcepub fn triggers(
self,
triggers: impl IntoIterator<Item = impl Into<TriggerEntry>>,
) -> Self
pub fn triggers( self, triggers: impl IntoIterator<Item = impl Into<TriggerEntry>>, ) -> Self
Append triggers that autonomously wake the agent.
Sourcepub fn mcp_servers(
self,
servers: impl IntoIterator<Item = impl Into<McpServer>>,
) -> Self
pub fn mcp_servers( self, servers: impl IntoIterator<Item = impl Into<McpServer>>, ) -> Self
Append MCP servers for the agent.
Sourcepub fn skills(
self,
skills: impl IntoIterator<Item = impl Into<PathBuf>>,
) -> Self
pub fn skills( self, skills: impl IntoIterator<Item = impl Into<PathBuf>>, ) -> Self
Append paths for agent skills.
Sourcepub fn max_quota_retries(self, retries: u32) -> Self
pub fn max_quota_retries(self, retries: u32) -> Self
Set the maximum number of quota retry attempts before giving up.
Sourcepub async fn build(self) -> Result<Agent, Error>
pub async fn build(self) -> Result<Agent, Error>
Validate configuration and create the agent.
Prefer using .await directly on the builder (via IntoFuture)
instead of calling this method explicitly.
§Errors
Returns error::Error::InvalidConfig if:
config.toolsis non-empty and aToolRegistrywas provided.- The capabilities configuration is self-contradictory (e.g. both
enabled_toolsanddisabled_toolsspecified).
Returns other error::Error variants if agent creation fails.