pub trait AgentFactory: Send + Sync {
// Required methods
fn assess(&self, record: &AgentRecord) -> AgentAssessment;
fn ceiling<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
agent: &'life1 AgentId,
session: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentCeiling>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn choices<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AgentChoices>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn build<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 AgentRecord,
) -> Pin<Box<dyn Future<Output = Result<HostedAgent>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn retired<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 AgentRecord,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn ceiling_in<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
agent: &'life1 AgentId,
session: &'life2 str,
area: &'life3 PartitionId,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentCeiling>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn screen<'life0, 'async_trait>(
&'life0 self,
definition: AgentDefinition,
) -> Pin<Box<dyn Future<Output = AgentDefinition> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn reserved_ids(&self) -> Vec<String> { ... }
fn reserved_names(&self) -> Vec<String> { ... }
}Expand description
How a host builds the agents a person adds (spec 3.3 §5.7, §10 K7), registered with
KernelBuilder::agent_factory beside the agent store. adk-rust up’s factory builds a
harness agent with the composition the primary agent uses.
The kernel adds its own checks on top of assess and
ceiling: the risk of the agent’s drivers by their effect class, its
mode at most its area’s, its limit at most its area’s; the higher risk wins.
§Example
use std::sync::Arc;
use adk_core::{AgentId, ApprovalRisk};
use adk_kernel::agents::{
AgentAssessment, AgentCeiling, AgentChoices, AgentFactory, AgentRecord, HostedAgent,
};
use async_trait::async_trait;
struct Fixed(Arc<adk_runner::Runner>);
#[async_trait]
impl AgentFactory for Fixed {
fn assess(&self, _record: &AgentRecord) -> AgentAssessment {
AgentAssessment::new(ApprovalRisk::Low)
}
async fn ceiling(&self, _agent: &AgentId, _session: &str) -> adk_kernel::Result<Option<AgentCeiling>> {
Ok(None)
}
async fn choices(&self) -> adk_kernel::Result<AgentChoices> {
Ok(AgentChoices::default())
}
async fn build(&self, _record: &AgentRecord) -> adk_kernel::Result<HostedAgent> {
Ok(HostedAgent::new(self.0.clone()))
}
async fn retired(&self, _record: &AgentRecord) -> adk_kernel::Result<u64> {
Ok(0)
}
}Required Methods§
Sourcefn assess(&self, record: &AgentRecord) -> AgentAssessment
fn assess(&self, record: &AgentRecord) -> AgentAssessment
The risk, money and abilities of record’s definition (spec 3.3 §5.7’s risk table).
Sourcefn ceiling<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
agent: &'life1 AgentId,
session: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentCeiling>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn ceiling<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
agent: &'life1 AgentId,
session: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentCeiling>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
The suggesting agent agent’s limits now, in session, the session it suggested
in; None when it may suggest nothing.
§Errors
Returns the host’s error; the kernel then refuses the suggestion.
Sourcefn choices<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AgentChoices>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn choices<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AgentChoices>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
What a person may choose for an agent: the models whose key the host has, and the packs.
§Errors
Returns the host’s error.
Sourcefn build<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 AgentRecord,
) -> Pin<Box<dyn Future<Output = Result<HostedAgent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn build<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 AgentRecord,
) -> Pin<Box<dyn Future<Output = Result<HostedAgent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Builds record, an active or paused agent, with its root agent named by its id.
§Errors
Returns why it cannot be built, such as a missing key; the kernel keeps the record and shows the agent as “Can’t start” with the reason.
Sourcefn retired<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 AgentRecord,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn retired<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 AgentRecord,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called once when record is removed: revokes the standing rules pinned to it and
answers how many it revoked.
§Errors
Returns the host’s error; the next tick calls it again.
Provided Methods§
Sourcefn ceiling_in<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
agent: &'life1 AgentId,
session: &'life2 str,
area: &'life3 PartitionId,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentCeiling>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn ceiling_in<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
agent: &'life1 AgentId,
session: &'life2 str,
area: &'life3 PartitionId,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentCeiling>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
The suggesting agent agent’s limits now in session, as the agent of area, the
area it suggests in: a host that runs one agent per area answers with that area’s
limits, its drivers included (spec 3.3 S-I12). By default ceiling.
§Errors
Returns the host’s error; the kernel then refuses the suggestion.
Sourcefn screen<'life0, 'async_trait>(
&'life0 self,
definition: AgentDefinition,
) -> Pin<Box<dyn Future<Output = AgentDefinition> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn screen<'life0, 'async_trait>(
&'life0 self,
definition: AgentDefinition,
) -> Pin<Box<dyn Future<Output = AgentDefinition> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
definition as the kernel keeps an agent a person sets up by hand: its instructions
with secrets redacted and injection patterns labelled, as fetched text is, and its
line with secrets redacted (spec 3.3 §5.7, spec 3.1 I47). Screening twice changes
nothing. By default as it is.
Sourcefn reserved_ids(&self) -> Vec<String>
fn reserved_ids(&self) -> Vec<String>
Ids no added agent may take beside the kernel’s own: member names, say.
Sourcefn reserved_names(&self) -> Vec<String>
fn reserved_names(&self) -> Vec<String>
Names no added agent may take, ignoring case: the primary agent’s display name.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".