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(skills): cool failed registry refreshes down for 45 seconds (#7082)
oxoxDev5fe9ace68890
diff --git a/crates/openhuman-core/src/skills/catalog/mod.rs b/crates/openhuman-core/src/skills/catalog/mod.rsindex 2789b84dc9..dd139ad4d5 100644--- a/crates/openhuman-core/src/skills/catalog/mod.rs+++ b/crates/openhuman-core/src/skills/catalog/mod.rs@@ -29,7 +29,9 @@ mod transport;pub mod types;#[cfg(feature = "skills")]-pub use registry::{skill_registry, HERMES_REGISTRY_ID};+pub(crate) use registry::registry_timeouts;+#[cfg(feature = "skills")]+pub use registry::{skill_registry, HERMES_REGISTRY_ID, REFRESH_COOLDOWN};#[cfg(feature = "skills")]pub use transport::ReqwestTransport;diff --git a/crates/openhuman-core/src/skills/catalog/registry.rs b/crates/openhuman-core/src/skills/catalog/registry.rsindex 100d9e61ad..9071323e1d 100644--- a/crates/openhuman-core/src/skills/catalog/registry.rs+++ b/crates/openhuman-core/src/skills/catalog/registry.rs@@ -7,14 +7,22 @@//! | `OPENHUMAN_SKILL_INSTALL_ALLOW_LOCAL_HTTP=1` | Allow plain `http` to loopback (fixtures, local mirrors) |//! | `OPENHUMAN_SKILL_REGISTRY_CACHE_DIR` | Catalog store directory; default `~/.openhuman/skill-registry` |//!+//! A failed catalog refresh is not attempted again for [`REFRESH_COOLDOWN`]+//! (or longer when the upstream sends `Retry-After`); reads in that window+//! answer from the held catalog or with the last error.+//!//! The handle is rebuilt whenever that configuration changes, so a process//! that re-points the environment (tests, a relocated home) gets a registry//! for its current settings.use std::path::{Path, PathBuf};use std::sync::{Arc, PoisonError, RwLock};+use std::time::Duration;-use tinyskills::{FetchPolicy, FileCatalogStore, HermesIndexSource, RegistryLimits, SkillRegistry};+use tinyskills::{+ FetchPolicy, FileCatalogStore, HermesIndexSource, RegistryLimits, RegistryTimeouts,+ SkillRegistry,+};use super::transport::ReqwestTransport;@@ -24,6 +32,9 @@ const CACHE_DIR_ENV: &str = "OPENHUMAN_SKILL_REGISTRY_CACHE_DIR";const DEFAULT_CACHE_DIR: &str = "skill-registry";const LEGACY_CACHE_FILE: &str = "cache.json";+/// Minimum wait after a failed catalog refresh before the next one.+pub const REFRESH_COOLDOWN: Duration = Duration::from_secs(45);+/// The registry id of the Hermes index source.pub const HERMES_REGISTRY_ID: &str = "hermes";@@ -89,10 +100,17 @@ impl RegistryConfig {limits}+ pub(crate) fn timeouts() -> RegistryTimeouts {+ let mut timeouts = RegistryTimeouts::default();+ timeouts.cooldown = REFRESH_COOLDOWN;+ timeouts+ }+fn build(&self) -> Arc<SkillRegistry> {let builder = SkillRegistry::builder(ReqwestTransport::new()).source(self.source()).policy(self.policy())+ .timeouts(Self::timeouts()).limits(Self::limits());match &self.cache_dir {Some(dir) => {@@ -123,6 +141,11 @@ fn remove_legacy_cache(dir: &Path) {}}+/// The time budgets every registry fetch in this process uses.+pub(crate) fn registry_timeouts() -> RegistryTimeouts {+ RegistryConfig::timeouts()+}+static HANDLE: RwLock<Option<(RegistryConfig, Arc<SkillRegistry>)>> = RwLock::new(None);/// The registry for the current environment, built on first use.diff --git a/crates/openhuman-core/src/skills/catalog/registry_tests.rs b/crates/openhuman-core/src/skills/catalog/registry_tests.rsindex ee99b18be5..649830e6e5 100644--- a/crates/openhuman-core/src/skills/catalog/registry_tests.rs+++ b/crates/openhuman-core/src/skills/catalog/registry_tests.rs@@ -103,3 +103,14 @@ fn building_removes_the_legacy_cache_file() {let _registry = config.build();assert!(!legacy.exists(), "the pre-registry cache is dropped");}++#[test]+fn a_failed_refresh_cools_down_for_45_seconds() {+ assert_eq!(REFRESH_COOLDOWN, std::time::Duration::from_secs(45));+ assert_eq!(RegistryConfig::timeouts().cooldown, REFRESH_COOLDOWN);+ assert_eq!(registry_timeouts().cooldown, REFRESH_COOLDOWN);+ let defaults = RegistryTimeouts::default();+ let timeouts = RegistryConfig::timeouts();+ assert_eq!(timeouts.document, defaults.document);+ assert_eq!(timeouts.catalog, defaults.catalog);+}