The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(agent): add memory block spec to agent definitions
Steven Enamakelbeab807197fc
diff --git a/crates/openhuman-embed/src/agent/definition.rs b/crates/openhuman-embed/src/agent/definition.rsindex f4b90284bf..c011dacb62 100644--- a/crates/openhuman-embed/src/agent/definition.rs+++ b/crates/openhuman-embed/src/agent/definition.rs@@ -50,6 +50,15 @@ pub enum SandboxModeSpec {Sandboxed,}+/// A memory block at the end of an agent's system prompt; see+/// [`AgentDefinitionSpec::memory_block`].+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub struct MemoryBlockSpec {+ /// The most tokens the block may take, its markers and instruction line+ /// included. Memories past the budget are left out, beliefs first in.+ pub max_tokens: u32,+}+/// Starting definition: a named built-in or a complete host-supplied definition.#[derive(Debug, Clone)]pub enum DefinitionBase {@@ -82,6 +91,7 @@ pub struct AgentDefinitionSpec {/// The prompt is the whole system prompt, with nothing composed around it.bare_prompt: bool,refresh_prompt_on_resume: Option<bool>,+ memory_block: Option<MemoryBlockSpec>,tools: Option<ToolScopeSpec>,disallowed_tools: Vec<String>,tool_rules: Option<tinytools::ToolRules>,@@ -149,6 +159,7 @@ impl AgentDefinitionSpec {self.refresh_prompt_on_resume = self.refresh_prompt_on_resume.or(lower.refresh_prompt_on_resume);+ self.memory_block = self.memory_block.or(lower.memory_block);self.tools = self.tools.or(lower.tools);self.disallowed_tools.extend(lower.disallowed_tools);// Tool rules must retain both layers' restrictions; core also enforces config rules.@@ -216,6 +227,28 @@ impl AgentDefinitionSpec {self}+ /// End the system prompt with what long-term memory knows about the user.+ ///+ /// The block is read from the agent's [`MemoryBinding`](crate::MemoryBinding):+ /// the beliefs memory built, then the durable learnings at its root,+ /// within `spec.max_tokens`, between `<memory>` and `</memory>` and+ /// introduced as background knowledge, not instructions. It is the+ /// prompt's last system message, after every static byte.+ ///+ /// It is rendered only when a transcript generation starts: a new+ /// thread, a resumed thread recorded without one, a turn whose prompt+ /// changes anyway ([`refresh_prompt_on_resume`](Self::refresh_prompt_on_resume)),+ /// and the first turn after a compaction carried an old block into a new+ /// generation. Every other turn re-sends the recorded block byte for+ /// byte, so the provider's prefix cache stays warm, and a memory change+ /// on its own never seals a generation nor adds the prompt-update note.+ /// Nothing remembered sends no block; a memory read error sends whatever+ /// the thread recorded (none on a new thread) and the turn goes on.+ pub fn memory_block(mut self, spec: MemoryBlockSpec) -> Self {+ self.memory_block = Some(spec);+ self+ }+/// Whether this is a [`ToolScopeSpec::HostOnly`] definition.pub(crate) fn is_host_only(&self) -> bool {matches!(self.tools, Some(ToolScopeSpec::HostOnly))diff --git a/crates/openhuman-embed/src/agent/mod.rs b/crates/openhuman-embed/src/agent/mod.rsindex 20c1ddadd9..61272444b9 100644--- a/crates/openhuman-embed/src/agent/mod.rs+++ b/crates/openhuman-embed/src/agent/mod.rs@@ -27,7 +27,9 @@ mod definition;mod layout;pub(crate) mod spec;-pub use definition::{AgentDefinitionSpec, DefinitionBase, SandboxModeSpec, ToolScopeSpec};+pub use definition::{+ AgentDefinitionSpec, DefinitionBase, MemoryBlockSpec, SandboxModeSpec, ToolScopeSpec,+};pub use layout::AgentLayout;pub use spec::{AgentSpec, MemoryBinding};diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rsindex 8c4ed0adad..7593724858 100644--- a/crates/openhuman-embed/src/lib.rs+++ b/crates/openhuman-embed/src/lib.rs@@ -176,7 +176,7 @@ pub use openhuman_core::voice::VOICE_COMPILED_IN;pub use agent::ToolAttachmentError;pub use agent::{Agent, AgentDefinitionSpec, AgentError, AgentLayout, AgentSpec, ApprovalDecision, Approvals,- ApprovalsError, DefinitionBase, MemoryBinding, PendingApproval, SandboxModeSpec, ToolScopeSpec,+ ApprovalsError, DefinitionBase, MemoryBinding, MemoryBlockSpec, PendingApproval, SandboxModeSpec, ToolScopeSpec,};pub use auth::{Auth, AuthState, Session};#[cfg(feature = "channels")]