Skip to main content

atomr_agents_core/
memory.rs

1use serde::{Deserialize, Serialize};
2
3use crate::ids::{AgentId, OrgId, TeamId};
4use crate::value::Value;
5
6/// Stored unit. The strategy decides what to put in `payload`.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct MemoryItem {
9    pub id: String,
10    pub kind: MemoryKind,
11    pub namespace: MemoryNamespace,
12    pub payload: Value,
13    pub timestamp_ms: i64,
14    #[serde(default)]
15    pub tags: Vec<String>,
16}
17
18/// Retrieval unit. Memory strategies emit chunks; the assembler packs
19/// them into the prompt under the shared budget.
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct MemoryChunk {
22    pub source_id: String,
23    pub text: String,
24    pub score: f32,
25    pub estimated_tokens: u32,
26}
27
28#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
29#[serde(rename_all = "snake_case")]
30pub enum MemoryKind {
31    Episodic,
32    Semantic,
33    Working,
34    Scratchpad,
35}
36
37/// Where a memory item lives in the org/team/agent hierarchy.
38/// Reads cascade outward (agent → team → org); writes are gated by
39/// policy.
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub enum MemoryNamespace {
42    Agent(AgentId),
43    Team(TeamId),
44    Org(OrgId),
45}