pub struct AgentLoopBuilder<Ctx, P, H, M, S> { /* private fields */ }Expand description
Implementations§
Source§impl<Ctx, P, H, M, S> AgentLoopBuilder<Ctx, P, H, M, S>
impl<Ctx, P, H, M, S> AgentLoopBuilder<Ctx, P, H, M, S>
Sourcepub fn provider<P2: LlmProvider>(
self,
provider: P2,
) -> AgentLoopBuilder<Ctx, P2, H, M, S>
pub fn provider<P2: LlmProvider>( self, provider: P2, ) -> AgentLoopBuilder<Ctx, P2, H, M, S>
Set the LLM provider.
Sourcepub fn tools(self, tools: ToolRegistry<Ctx>) -> Self
pub fn tools(self, tools: ToolRegistry<Ctx>) -> Self
Set the tool registry.
Sourcepub fn hooks<H2: AgentHooks>(
self,
hooks: H2,
) -> AgentLoopBuilder<Ctx, P, H2, M, S>
pub fn hooks<H2: AgentHooks>( self, hooks: H2, ) -> AgentLoopBuilder<Ctx, P, H2, M, S>
Set the agent hooks.
Sourcepub fn message_store<M2: MessageStore>(
self,
message_store: M2,
) -> AgentLoopBuilder<Ctx, P, H, M2, S>
pub fn message_store<M2: MessageStore>( self, message_store: M2, ) -> AgentLoopBuilder<Ctx, P, H, M2, S>
Set the message store.
Sourcepub fn state_store<S2: StateStore>(
self,
state_store: S2,
) -> AgentLoopBuilder<Ctx, P, H, M, S2>
pub fn state_store<S2: StateStore>( self, state_store: S2, ) -> AgentLoopBuilder<Ctx, P, H, M, S2>
Set the state store.
Sourcepub fn config(self, config: AgentConfig) -> Self
pub fn config(self, config: AgentConfig) -> Self
Set the agent configuration.
Sourcepub const fn with_compaction(self, config: CompactionConfig) -> Self
pub const fn with_compaction(self, config: CompactionConfig) -> Self
Enable context compaction with the given configuration.
When enabled, the agent will automatically compact conversation history when it exceeds the configured token threshold.
§Example
use agent_sdk::{builder, context::CompactionConfig};
let agent = builder()
.provider(my_provider)
.with_compaction(CompactionConfig::default())
.build();Sourcepub fn with_auto_compaction(self) -> Self
pub fn with_auto_compaction(self) -> Self
Enable context compaction with default settings.
This is a convenience method equivalent to:
builder.with_compaction(CompactionConfig::default())Sourcepub fn with_skill(self, skill: Skill) -> Self
pub fn with_skill(self, skill: Skill) -> Self
Apply a skill configuration.
This merges the skill’s system prompt with the existing configuration and filters tools based on the skill’s allowed/denied lists.
§Example
let skill = Skill::new("code-review", "You are a code reviewer...")
.with_denied_tools(vec!["bash".into()]);
let agent = builder()
.provider(provider)
.tools(tools)
.with_skill(skill)
.build();Source§impl<Ctx, P> AgentLoopBuilder<Ctx, P, (), (), ()>
impl<Ctx, P> AgentLoopBuilder<Ctx, P, (), (), ()>
Sourcepub fn build(
self,
) -> AgentLoop<Ctx, P, DefaultHooks, InMemoryStore, InMemoryStore>
pub fn build( self, ) -> AgentLoop<Ctx, P, DefaultHooks, InMemoryStore, InMemoryStore>
Build the agent loop with default hooks and in-memory stores.
This is a convenience method that uses:
DefaultHooksfor hooksInMemoryStorefor message storeInMemoryStorefor state storeAgentConfig::default()if no config is set
§Panics
Panics if a provider has not been set.
Source§impl<Ctx, P, H, M, S> AgentLoopBuilder<Ctx, P, H, M, S>where
Ctx: Send + Sync + 'static,
P: LlmProvider + 'static,
H: AgentHooks + 'static,
M: MessageStore + 'static,
S: StateStore + 'static,
impl<Ctx, P, H, M, S> AgentLoopBuilder<Ctx, P, H, M, S>where
Ctx: Send + Sync + 'static,
P: LlmProvider + 'static,
H: AgentHooks + 'static,
M: MessageStore + 'static,
S: StateStore + 'static,
Sourcepub fn build_with_stores(self) -> AgentLoop<Ctx, P, H, M, S>
pub fn build_with_stores(self) -> AgentLoop<Ctx, P, H, M, S>
Build the agent loop with all custom components.
§Panics
Panics if any of the following have not been set:
providerhooksmessage_storestate_store