pub struct ConfigurableAgent { /* private fields */ }Expand description
A configurable agent that derives its behavior from TOML configuration
Implementations§
Source§impl ConfigurableAgent
impl ConfigurableAgent
Sourcepub fn new(
name: &str,
config: &AgentConfig,
llm: Box<dyn LLMClient>,
tools: Option<Arc<Tools>>,
) -> Self
👎Deprecated: use new_with_tool_service with ctx.get::<dyn ToolService>()
pub fn new( name: &str, config: &AgentConfig, llm: Box<dyn LLMClient>, tools: Option<Arc<Tools>>, ) -> Self
use new_with_tool_service with ctx.get::<dyn ToolService>()
Create a new configurable agent from TOML config
Deprecated shim kept for one commit. New code should use
new_with_tool_service with a service obtained via
ctx.get::<dyn ToolService>().
Sourcepub fn new_with_provider(
name: &str,
config: &AgentConfig,
llm: Box<dyn LLMClient>,
tools: Option<Arc<Tools>>,
provider_name: String,
) -> Self
👎Deprecated: use new_with_provider_and_tool_service with ctx.get::<dyn ToolService>()
pub fn new_with_provider( name: &str, config: &AgentConfig, llm: Box<dyn LLMClient>, tools: Option<Arc<Tools>>, provider_name: String, ) -> Self
use new_with_provider_and_tool_service with ctx.get::<dyn ToolService>()
Create a new configurable agent with explicit provider metadata
Deprecated shim. Prefer new_with_provider_and_tool_service.
Sourcepub fn with_params(
name: &str,
agent_type: AgentType,
llm: Box<dyn LLMClient>,
system_prompt: String,
tools: Option<Arc<Tools>>,
allowed_tools: Option<Vec<String>>,
max_tool_iterations: usize,
parallel_tools: bool,
) -> Self
👎Deprecated: use with_tool_service_params with ctx.get::<dyn ToolService>()
pub fn with_params( name: &str, agent_type: AgentType, llm: Box<dyn LLMClient>, system_prompt: String, tools: Option<Arc<Tools>>, allowed_tools: Option<Vec<String>>, max_tool_iterations: usize, parallel_tools: bool, ) -> Self
use with_tool_service_params with ctx.get::<dyn ToolService>()
Create a new configurable agent with explicit parameters
Deprecated shim. Prefer with_tool_service_params.
Sourcepub fn new_with_tool_service(
name: &str,
config: &AgentConfig,
llm: Box<dyn LLMClient>,
tool_service: Option<Arc<Tools>>,
) -> Self
pub fn new_with_tool_service( name: &str, config: &AgentConfig, llm: Box<dyn LLMClient>, tool_service: Option<Arc<Tools>>, ) -> Self
Create an agent wired to a unified ToolService.
Obtain the service via ctx.get::<dyn ToolService>() and pass it here.
This is the Cordis DI path. The service provides all tools with tenant
precedence already handled.
Sourcepub fn new_with_provider_and_tool_service(
name: &str,
config: &AgentConfig,
llm: Box<dyn LLMClient>,
tool_service: Option<Arc<Tools>>,
provider_name: String,
) -> Self
pub fn new_with_provider_and_tool_service( name: &str, config: &AgentConfig, llm: Box<dyn LLMClient>, tool_service: Option<Arc<Tools>>, provider_name: String, ) -> Self
Create an agent with provider metadata and a unified ToolService.
Sourcepub fn set_compaction(&mut self, enabled: bool)
pub fn set_compaction(&mut self, enabled: bool)
Enable per-session history compaction for this agent.
Sourcepub fn with_tool_service_params(
name: &str,
agent_type: AgentType,
llm: Box<dyn LLMClient>,
system_prompt: String,
tool_service: Option<Arc<Tools>>,
allowed_tools: Option<Vec<String>>,
max_tool_iterations: usize,
parallel_tools: bool,
) -> Self
pub fn with_tool_service_params( name: &str, agent_type: AgentType, llm: Box<dyn LLMClient>, system_prompt: String, tool_service: Option<Arc<Tools>>, allowed_tools: Option<Vec<String>>, max_tool_iterations: usize, parallel_tools: bool, ) -> Self
Create an agent with explicit parameters and a unified ToolService.
Sourcepub fn new_from_context(
ctx: &Arc<Context>,
name: &str,
config: &AgentConfig,
llm: Box<dyn LLMClient>,
) -> Self
pub fn new_from_context( ctx: &Arc<Context>, name: &str, config: &AgentConfig, llm: Box<dyn LLMClient>, ) -> Self
Create an agent by resolving the ToolService from a Context.
This is the one line handlers should use: ConfigurableAgent::new_from_context(&ctx, name, &config, llm).
Sourcepub fn new_from_context_with_provider(
ctx: &Arc<Context>,
name: &str,
config: &AgentConfig,
llm: Box<dyn LLMClient>,
provider_name: String,
) -> Self
pub fn new_from_context_with_provider( ctx: &Arc<Context>, name: &str, config: &AgentConfig, llm: Box<dyn LLMClient>, provider_name: String, ) -> Self
Same as new_from_context but with explicit provider name.
Sourcepub fn max_tool_iterations(&self) -> usize
pub fn max_tool_iterations(&self) -> usize
Get the max tool iterations setting
Sourcepub fn parallel_tools(&self) -> bool
pub fn parallel_tools(&self) -> bool
Get the parallel tools setting
Sourcepub fn has_tools(&self) -> bool
pub fn has_tools(&self) -> bool
Check if this agent may use tools (built-in or tenant-scoped via Tools).
Sourcepub fn set_tools(&mut self, tools: Arc<Tools>)
pub fn set_tools(&mut self, tools: Arc<Tools>)
Store the unified Tools capability used for list/resolve/dispatch.
Sourcepub fn bind_request_ctx(&mut self, ctx: Arc<Context>)
pub fn bind_request_ctx(&mut self, ctx: Arc<Context>)
Bind the request Cordis context so tool isolate labels and
ExternalContext are visible during execute.
Sourcepub fn allowed_tools(&self) -> Option<&[String]>
pub fn allowed_tools(&self) -> Option<&[String]>
Get the list of allowed tool names for this agent.
None means no tools are permitted.
Sourcepub fn set_allowed_tools(&mut self, allowed_tools: Option<Vec<String>>)
pub fn set_allowed_tools(&mut self, allowed_tools: Option<Vec<String>>)
Override the allowed tools list at runtime (e.g. after merging with a per-tenant allowlist).
Sourcepub fn set_observability(&mut self, obs: Arc<dyn ObservabilitySink>)
pub fn set_observability(&mut self, obs: Arc<dyn ObservabilitySink>)
Attach an observability sink to this agent.
Sourcepub fn set_fallback_llms(&mut self, fallbacks: Vec<Box<dyn LLMClient>>)
pub fn set_fallback_llms(&mut self, fallbacks: Vec<Box<dyn LLMClient>>)
Set fallback LLM clients to try if the primary fails.
Sourcepub fn set_fallback_llms_with_providers(
&mut self,
fallbacks: Vec<(String, Box<dyn LLMClient>)>,
)
pub fn set_fallback_llms_with_providers( &mut self, fallbacks: Vec<(String, Box<dyn LLMClient>)>, )
Set fallback LLM clients with provider names for observability and billing metadata.
Sourcepub fn set_run_id(&mut self, run_id: String)
pub fn set_run_id(&mut self, run_id: String)
Set the run id to associate with token usage records.
Sourcepub fn get_filtered_tool_definitions(&self) -> Vec<ToolDefinition>
pub fn get_filtered_tool_definitions(&self) -> Vec<ToolDefinition>
Get tool definitions for this agent.
If allowed_tools is set, returns only those tools (if enabled).
Otherwise returns no tools: tool use is deny-by-default.
Sourcepub fn can_use_tool(&self, tool_name: &str) -> bool
pub fn can_use_tool(&self, tool_name: &str) -> bool
Check if a specific tool is allowed for this agent. When no whitelist is set, no tool is allowed.
Trait Implementations§
Source§impl Agent for ConfigurableAgent
impl Agent for ConfigurableAgent
Source§fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
input: &'life1 str,
context: &'life2 AgentContext,
) -> Pin<Box<dyn Future<Output = Result<AgentResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
input: &'life1 str,
context: &'life2 AgentContext,
) -> Pin<Box<dyn Future<Output = Result<AgentResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn system_prompt(&self) -> String
fn system_prompt(&self) -> String
Source§fn agent_type(&self) -> AgentType
fn agent_type(&self) -> AgentType
Auto Trait Implementations§
impl !RefUnwindSafe for ConfigurableAgent
impl !UnwindSafe for ConfigurableAgent
impl Freeze for ConfigurableAgent
impl Send for ConfigurableAgent
impl Sync for ConfigurableAgent
impl Unpin for ConfigurableAgent
impl UnsafeUnpin for ConfigurableAgent
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<T> ErasedDestructor for Twhere
T: 'static,
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 moreimpl<T> MaybeSendSync for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.