pub struct FactStore { /* private fields */ }Expand description
Manages facts for one agent across all actors.
Implementations§
Source§impl FactStore
impl FactStore
pub fn new( storage: Arc<dyn AgentStorage>, agent_id: String, config: FactsConfig, ) -> FactStore
Sourcepub async fn add_facts(
&self,
actor_id: &str,
facts: Vec<KeyFact>,
) -> Result<Vec<KeyFact>, AgentError>
pub async fn add_facts( &self, actor_id: &str, facts: Vec<KeyFact>, ) -> Result<Vec<KeyFact>, AgentError>
Add new facts for an actor, enforcing max_facts by evicting lowest priority rows. Returns the authoritative post-write set of facts for the actor so callers can refresh their cache without re-reading from storage.
Sourcepub async fn get_facts(
&self,
actor_id: &str,
) -> Result<Vec<KeyFact>, AgentError>
pub async fn get_facts( &self, actor_id: &str, ) -> Result<Vec<KeyFact>, AgentError>
Load all facts for an actor.
Sourcepub async fn get_facts_by_category(
&self,
actor_id: &str,
category: &FactCategory,
) -> Result<Vec<KeyFact>, AgentError>
pub async fn get_facts_by_category( &self, actor_id: &str, category: &FactCategory, ) -> Result<Vec<KeyFact>, AgentError>
Load facts filtered by category.
Sourcepub async fn query(
&self,
filter: &FactFilter,
) -> Result<Vec<KeyFact>, AgentError>
pub async fn query( &self, filter: &FactFilter, ) -> Result<Vec<KeyFact>, AgentError>
Query facts across actors.
Sourcepub async fn delete_fact(
&self,
actor_id: &str,
fact_id: &str,
) -> Result<(), AgentError>
pub async fn delete_fact( &self, actor_id: &str, fact_id: &str, ) -> Result<(), AgentError>
Delete a specific fact.
Sourcepub async fn delete_actor_data(&self, actor_id: &str) -> Result<(), AgentError>
pub async fn delete_actor_data(&self, actor_id: &str) -> Result<(), AgentError>
Delete all data for an actor (facts + sessions). Privacy compliance.
Sourcepub fn format_for_context(&self, facts: &[KeyFact], max_tokens: usize) -> String
pub fn format_for_context(&self, facts: &[KeyFact], max_tokens: usize) -> String
Format facts as a string for chat-time system prompt injection.
Output is a plain bulleted list of fact statements, ordered by priority,
truncated to fit max_tokens. Category labels and confidence scores are
intentionally omitted because they look like metadata noise to the chat
LLM and have caused the model to hedge (“I don’t know your identity”)
even when the facts clearly state the user’s name.
Use the extractor’s separate prompt format when feeding facts back into the fact extractor for dedup guidance.
Sourcepub fn config(&self) -> &FactsConfig
pub fn config(&self) -> &FactsConfig
Get the underlying config.
Auto Trait Implementations§
impl !RefUnwindSafe for FactStore
impl !UnwindSafe for FactStore
impl Freeze for FactStore
impl Send for FactStore
impl Sync for FactStore
impl Unpin for FactStore
impl UnsafeUnpin for FactStore
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
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 more