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
fix(agent): correct fleet prompt test to use valid agent id
Steven Enamakel570d558ccc17
diff --git a/crates/openhuman-core/src/agent/registry/agents/fleet_prompt_tests.rs b/crates/openhuman-core/src/agent/registry/agents/fleet_prompt_tests.rsindex 956a4af357..b612f9bf21 100644--- a/crates/openhuman-core/src/agent/registry/agents/fleet_prompt_tests.rs+++ b/crates/openhuman-core/src/agent/registry/agents/fleet_prompt_tests.rs@@ -337,7 +337,7 @@ fn every_prompt_names_only_tools_its_agent_can_call() {/// Agents whose prompt defers to the rendered tool list instead of naming a/// tool; [`every_prompt_names_at_least_one_tool_it_can_call`] skips them.-const NAMES_NO_TOOL: &[&str] = &["critic", "archivist"];+const NAMES_NO_TOOL: &[&str] = &["critic"];const SKILL_SETUP_NAME: Option<&str> = if cfg!(feature = "skills") {Some("skill_setup")diff --git a/crates/openhuman-core/src/flows/bus/run_digest.rs b/crates/openhuman-core/src/flows/bus/run_digest.rsindex 8d2f4d9f22..8d0bf64232 100644--- a/crates/openhuman-core/src/flows/bus/run_digest.rs+++ b/crates/openhuman-core/src/flows/bus/run_digest.rs@@ -1,91 +1,62 @@-//! Post-run memory digest: [`FlowRunDigestSubscriber`] writes a compact,-//! bounded summary of every successful run into the flow's private memory-//! namespace so later runs can recall what they already did.+//! Post-run memory digest: [`FlowRunDigestSubscriber`] stores a compact,+//! bounded summary of every successful run as a memory document tagged with+//! the flow ([`flow_tag`]) and [`FLOW_RUN_DIGEST_TAG`], so later runs can+//! recall what they already did.use crate::config::Config;use crate::core::events::DomainEvent;use crate::flows::store;-use crate::flows::{flow_namespace, FlowRun};+use crate::flows::{flow_meta, flow_tag, FlowRun};+use crate::memory::types::{ForgetParams, ItemsListParams, MAX_LIMIT};+use crate::memory::{MemoryError, MemoryResult};use async_trait::async_trait;use std::sync::Arc;use tinybus::EventHandler;-use tinymemory_api::provider::MemoryCore;-use tinymemory_api::types::{MemoryCategory, MemoryTaint};+use tinymemory::{ItemKind, MetaFilter, StoreItem};/// Bounds a post-run memory digest to a compact, LLM-cheap size — a single/// run's summary must never dominate a later `flow_memory_recall`.pub(super) const DIGEST_MAX_CHARS: usize = 1000;-/// Cap on how many `run_digest:*` entries [`FlowRunDigestSubscriber`] keeps-/// per flow's memory namespace before pruning the oldest.-const DIGEST_RETENTION_CAP: usize = 50;+/// Cap on how many run digests [`FlowRunDigestSubscriber`] keeps per flow+/// before forgetting the oldest.+pub(super) const DIGEST_RETENTION_CAP: usize = 50;++/// Tag carried by every post-run digest document.+pub(super) const FLOW_RUN_DIGEST_TAG: &str = "flow_run_digest";++/// The filter matching `flow_id`'s run digests: the flow's own source id+/// (stamped by [`flow_meta`]) AND the digest tag.+pub(super) fn digest_filter(flow_id: &str) -> MetaFilter {+ MetaFilter {+ kinds: vec![ItemKind::Document],+ source_id: Some(flow_tag(flow_id)),+ tags_any: vec![FLOW_RUN_DIGEST_TAG.to_string()],+ ..MetaFilter::default()+ }+}/// Listens for `DomainEvent::FlowRunFinished` and, on a successful terminal-/// status, writes a compact digest of the run into the flow's own private-/// memory namespace ([`flow_namespace`]) — e.g. so a later run of the same-/// scheduled digest flow can `flow_memory_recall` what it already sent-/// without re-deriving that from the target service.+/// status, stores a compact digest of the run in the flow's own memory —+/// e.g. so a later run of the same scheduled digest flow can+/// `flow_memory_recall` what it already sent without re-deriving that from+/// the target service.////// Success-only: `"failed"` / `"cancelled"` / `"interrupted"` / any other/// terminal status is ignored, since a digest of a run that didn't actually/// complete its work would misleadingly look like a record of real output.///-/// Best-effort throughout: every failure here is logged via `tracing::warn!`-/// and swallowed, never propagated — by the time this subscriber observes-/// `FlowRunFinished`, the run has already settled its own `flow_runs` row, so-/// a memory-layer hiccup must never retroactively affect run status.+/// Best-effort throughout: memory off is a quiet skip, and every other+/// failure is logged and swallowed — by the time this subscriber observes+/// `FlowRunFinished` the run has settled its own `flow_runs` row, so a+/// memory hiccup must never retroactively affect run status.pub struct FlowRunDigestSubscriber {config: Arc<Config>,- /// Test-only memory override. In production this is `None` and the digest- /// resolves the process-global memory client via [`active_memory_client`].- /// The process-global client is a one-shot `OnceLock`, so a unit test- /// cannot reliably rebind it to its own tempdir (an earlier test in the- /// same binary may already have initialised the singleton — see- /// `memory::global`'s own test notes). Injecting a directly-constructed- /// [`Memory`] here lets the digest tests write and read back through the- /// SAME instance deterministically, exactly as `flows::memory_tools`'- /// tests do with `UnifiedMemory::new`.- memory_override: Option<Arc<crate::memory::guard::MemoryGuard>>,}impl FlowRunDigestSubscriber {pub fn new(config: Arc<Config>) -> Self {- Self {- config,- memory_override: None,- }- }-- /// Test constructor: run the digest against an explicitly-provided memory- /// instance instead of the process-global client. See [`Self::memory_override`].- #[cfg(test)]- pub(super) fn with_memory(- config: Arc<Config>,- memory: Arc<crate::memory::guard::MemoryGuard>,- ) -> Self {- Self {- config,- memory_override: Some(memory),- }- }-- /// Resolves the memory handle the digest writes to: the injected test- /// override when present, else the process-global client- /// ([`active_memory_client`]). Returns `None` (best-effort skip) when the- /// global client is unavailable.- async fn resolve_memory(&self) -> Option<Arc<crate::memory::guard::MemoryGuard>> {- if let Some(memory) = &self.memory_override {- return Some(memory.clone());- }- // The guarded driver, not the raw engine client. The digest writes- // through the policy layer like every other write.- match crate::memory::ops::guard::active_memory_guard().await {- Ok(guard) => Some(guard),- Err(e) => {- tracing::warn!(target: "flows", error = %e, "[flows] digest: memory unavailable — skipping");- None- }- }+ Self { config }}async fn handle_finished(&self, flow_id: &str, run_id: &str, status: &str) {@@ -93,6 +64,10 @@ impl FlowRunDigestSubscriber {tracing::trace!(target: "flows", %flow_id, %run_id, %status, "[flows] digest: ignoring non-success terminal status");return;}+ if !crate::memory::memory_is_on(&self.config) {+ tracing::debug!(target: "flows", %flow_id, %run_id, "[flows] digest: memory is off — skipping");+ return;+ }let flow_name = match store::get_flow(&self.config, flow_id) {Ok(Some(flow)) => flow.name,@@ -119,68 +94,75 @@ impl FlowRunDigestSubscriber {};let digest = render_run_digest(&flow_name, &run);-- let Some(memory) = self.resolve_memory().await else {- return;- };- let namespace = flow_namespace(flow_id);- let digest_key = format!("run_digest:{run_id}");-- // `store` carries the taint on the contract, so the separate- // `store_with_taint` door the engine trait needed is gone. The guard- // still stamps the effective value — `ExternalSync` here is the- // request, and it is the honest one: a digest is machine-generated- // from a flow run, not user-authored.- if let Err(e) = memory- .store(- &namespace,- &digest_key,- &digest,- MemoryCategory::Core,- None,- MemoryTaint::ExternalSync,- )- .await+ let mut meta = flow_meta(flow_id, &[FLOW_RUN_DIGEST_TAG.to_string()]);+ meta.observed_at = Some(chrono::Utc::now());+ match crate::memory::ops::store_item(&self.config, StoreItem::document(digest, meta)).await{- tracing::warn!(target: "flows", %flow_id, %run_id, %namespace, error = %e, "[flows] digest: failed to write run digest");- return;- }-- self.enforce_retention_cap(&memory, &namespace).await;- }-- /// Best-effort prune: keeps at most [`DIGEST_RETENTION_CAP`] `run_digest:*`- /// entries per flow namespace, evicting the oldest (by `timestamp`) first.- async fn enforce_retention_cap(- &self,- memory: &Arc<crate::memory::guard::MemoryGuard>,- namespace: &str,- ) {- let entries = match memory.list(Some(namespace), None, None).await {- Ok(entries) => entries,+ Ok(receipt) => {+ tracing::debug!(target: "flows", %flow_id, %run_id, replayed = receipt.replayed, "[flows] digest: run digest stored");+ }+ Err(MemoryError::Off(_)) => {+ tracing::debug!(target: "flows", %flow_id, %run_id, "[flows] digest: memory is off — skipping");+ return;+ }Err(e) => {- tracing::warn!(target: "flows", %namespace, error = %e, "[flows] digest: retention sweep failed to list namespace");+ tracing::warn!(target: "flows", %flow_id, %run_id, code = e.code(), error = %e, "[flows] digest: failed to store run digest");return;}- };- let mut digests: Vec<_> = entries- .into_iter()- .filter(|entry| entry.key.starts_with("run_digest:"))- .collect();- if digests.len() <= DIGEST_RETENTION_CAP {- return;}- // Oldest first, so the excess taken below is the stalest entries.- digests.sort_by(|a, b| a.timestamp.cmp(&b.timestamp));- let excess = digests.len() - DIGEST_RETENTION_CAP;- for entry in digests.into_iter().take(excess) {- if let Err(e) = memory.forget(namespace, &entry.key).await {- tracing::warn!(target: "flows", %namespace, key = %entry.key, error = %e, "[flows] digest: retention sweep failed to forget stale entry");++ match enforce_retention_cap(&self.config, flow_id, DIGEST_RETENTION_CAP).await {+ Ok(0) => {}+ Ok(forgotten) => {+ tracing::debug!(target: "flows", %flow_id, forgotten, "[flows] digest: retention sweep forgot stale digests");+ }+ Err(e) => {+ tracing::warn!(target: "flows", %flow_id, code = e.code(), error = %e, "[flows] digest: retention sweep failed");}}}}+/// Keeps at most `cap` run digests for `flow_id`, forgetting the oldest (by+/// `observed_at`) first. Returns how many were forgotten.+pub(super) async fn enforce_retention_cap(+ config: &Config,+ flow_id: &str,+ cap: usize,+) -> MemoryResult<usize> {+ let mut digests = Vec::new();+ let mut cursor = None;+ loop {+ let page = crate::memory::ops::items_list(+ config,+ ItemsListParams {+ filter: Some(digest_filter(flow_id)),+ limit: Some(MAX_LIMIT),+ cursor,+ },+ )+ .await?;+ digests.extend(page.items);+ match page.next_cursor {+ Some(next) => cursor = Some(next),+ None => break,+ }+ }+ if digests.len() <= cap {+ return Ok(0);+ }+ // Oldest first, so the excess taken below is the stalest digests.+ digests.sort_by(|a, b| a.meta.observed_at.cmp(&b.meta.observed_at));+ let excess = digests.len() - cap;+ let ids: Vec<String> = digests+ .into_iter()+ .take(excess)+ .map(|hit| hit.id.0)+ .collect();+ let view = crate::memory::ops::forget(config, ForgetParams { ids }).await?;+ Ok(view.forgotten)+}+#[async_trait]impl EventHandler<DomainEvent> for FlowRunDigestSubscriber {fn name(&self) -> &str {