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(skills): fail fast and name the reason when a skill fetch is refused
M3gA-Mind59ab60073f46
diff --git a/crates/openhuman-core/src/skills/catalog/ops.rs b/crates/openhuman-core/src/skills/catalog/ops.rsindex 4e46db7c11..f5e7485485 100644--- a/crates/openhuman-core/src/skills/catalog/ops.rs+++ b/crates/openhuman-core/src/skills/catalog/ops.rs@@ -392,7 +392,7 @@ pub async fn install_from_catalog(let params = crate::skills::ops_install::InstallWorkflowFromUrlParams {url,- timeout_secs: Some(60),+ timeout_secs: Some(CATALOG_INSTALL_TIMEOUT_SECS),};crate::skills::ops_install::install_workflow_from_url(workspace_dir, params)@@ -412,6 +412,18 @@ pub async fn install_from_catalog(})}+/// Wall-clock budget for a catalog-driven SKILL.md fetch.+///+/// Deliberately the same 15s as `download::PROBE_TIMEOUT_SECS` — the two bound+/// requests to the same hosts in the same flow, so tuning one without the other+/// is almost always a mistake. This path used the 60s+/// `DEFAULT_INSTALL_TIMEOUT_SECS` instead, which is the documented default for+/// the public `skills.install_from_url` tool and is left alone; a user clicking+/// Install in the registry is waiting on a UI, not scripting a long fetch, and+/// a minute of a disabled button with no reason was the whole of #6409's+/// reported symptom.+const CATALOG_INSTALL_TIMEOUT_SECS: u64 = 15;+/// How many alternative ids an install error lists.const MAX_SUGGESTED_IDS: usize = 5;diff --git a/crates/openhuman-core/src/skills/ops_install.rs b/crates/openhuman-core/src/skills/ops_install.rsindex 346b147e86..8bab88f9ed 100644--- a/crates/openhuman-core/src/skills/ops_install.rs+++ b/crates/openhuman-core/src/skills/ops_install.rs@@ -11,6 +11,7 @@ mod url_validation;pub use fetch::{install_workflow_from_url, InstallWorkflowFromUrlOutcome, InstallWorkflowFromUrlParams,DEFAULT_INSTALL_TIMEOUT_SECS, MAX_INSTALL_TIMEOUT_SECS, MAX_WORKFLOW_MD_BYTES,+ RATE_LIMITED_ERROR_PREFIX,};pub use uninstall::{uninstall_workflow, UninstallWorkflowOutcome, UninstallWorkflowParams};pub use url_validation::{validate_install_url, validate_resolved_host, MAX_INSTALL_URL_LEN};diff --git a/crates/openhuman-core/src/skills/ops_install/fetch.rs b/crates/openhuman-core/src/skills/ops_install/fetch.rsindex 1c86e0a7d5..c100571035 100644--- a/crates/openhuman-core/src/skills/ops_install/fetch.rs+++ b/crates/openhuman-core/src/skills/ops_install/fetch.rs@@ -33,6 +33,11 @@ fn redact_url(raw: &str) -> String {/// Default wall-clock budget for the SKILL.md fetch.pub const DEFAULT_INSTALL_TIMEOUT_SECS: u64 = 60;+/// Prefix on the error a throttled host produces, so callers can tell+/// "come back shortly" apart from "this host is unreachable" without parsing+/// a status code back out of prose. A `Retry-After` delay is appended when the+/// host sent a parseable one.+pub const RATE_LIMITED_ERROR_PREFIX: &str = "rate limited";/// Hard ceiling callers can request via `timeout_secs`.pub const MAX_INSTALL_TIMEOUT_SECS: u64 = 600;/// Upper bound on the fetched SKILL.md body. Single-file skills rarely exceed@@ -125,6 +130,22 @@ pub async fn install_workflow_from_url(.await}+/// Seconds from a `Retry-After` header, when it is the delta-seconds form.+///+/// RFC 9110 also permits an HTTP-date. We deliberately do not parse that: it+/// would pull in a date parser to serve a form GitHub's raw CDN does not send,+/// and the caller degrades correctly without it — the error still says the host+/// is throttling, just without a specific delay.+pub(crate) fn retry_after_secs(headers: &reqwest::header::HeaderMap) -> Option<u64> {+ headers+ .get(reqwest::header::RETRY_AFTER)?+ .to_str()+ .ok()?+ .trim()+ .parse::<u64>()+ .ok()+}+pub(crate) fn should_report_install_fetch_status(status: reqwest::StatusCode) -> bool {!status.is_success() && !status.is_client_error()}@@ -212,10 +233,30 @@ pub(crate) async fn install_workflow_from_url_with_home(// The `Err(msg)` return is unchanged in both cases so the UI always// surfaces the failure.let status_str = status.as_u16().to_string();- let msg = format!(- "fetch failed: {fetch_url} returned status {}",- status.as_u16()- );+ // Read `Retry-After` off the response BEFORE anything consumes the+ // body: `response.bytes()` below takes `response` by value, and a+ // header read afterwards is not available at all. (The same ordering+ // trap silently drops the header on the model-call path — see #6413.)+ let retry_after = retry_after_secs(response.headers());+ // A throttled host is a different user action from an unreachable one:+ // "try again shortly" versus "this host is not answering". Both were+ // previously the same opaque `returned status N` string, so the UI+ // could not tell the user which had happened (#6409).+ let msg = if status == reqwest::StatusCode::TOO_MANY_REQUESTS+ || (status.is_server_error() && retry_after.is_some())+ {+ match retry_after {+ Some(secs) => {+ format!("{RATE_LIMITED_ERROR_PREFIX} by {fetch_url}: retry after {secs}s")+ }+ None => format!("{RATE_LIMITED_ERROR_PREFIX} by {fetch_url}: retry shortly"),+ }+ } else {+ format!(+ "fetch failed: {fetch_url} returned status {}",+ status.as_u16()+ )+ };let report_msg = format!("fetch failed: {redacted_fetch_url} returned status {}",status.as_u16()diff --git a/crates/openhuman-core/src/skills/ops_install_failure_tests.rs b/crates/openhuman-core/src/skills/ops_install_failure_tests.rsnew file mode 100644index 0000000000..541c1d9fbd--- /dev/null+++ b/crates/openhuman-core/src/skills/ops_install_failure_tests.rs@@ -0,0 +1,124 @@+//! Install-time failure modes for the SKILL.md fetch (#6409).+//!+//! Split out of `ops_create_and_url_tests.rs`, which reached the 750-line+//! layout cap. These cases share a shape the happy-path install tests do not:+//! each drives `install_workflow_from_url_with_home` against a wiremock host+//! that answers with a *failure*, and asserts on the KIND of error produced —+//! a throttled host must be distinguishable from a missing skill, or the UI+//! cannot tell the user whether to wait or to give up.++use super::*;++/// #6409: a throttled host and an unreachable one must not produce the same+/// error. Both used to be `fetch failed: … returned status N` / a transport+/// string with nothing distinguishing them, so the UI could not tell the user+/// whether to wait or to give up.+///+/// Asserting "install fails" would pass on the code this replaces, so each case+/// asserts the *kind* it produces and, for 429, that the host's own+/// `Retry-After` survives into the message.+#[tokio::test]+async fn a_throttled_host_reports_rate_limiting_with_its_retry_after() {+ use wiremock::matchers::{method, path};+ use wiremock::{Mock, MockServer, ResponseTemplate};++ let server = MockServer::start().await;+ Mock::given(method("GET"))+ .and(path("/SKILL.md"))+ .respond_with(ResponseTemplate::new(429).insert_header("Retry-After", "42"))+ .mount(&server)+ .await;++ let workspace = tempfile::tempdir().unwrap();+ let home = tempfile::tempdir().unwrap();+ let error = install_workflow_from_url_with_home(+ workspace.path(),+ InstallWorkflowFromUrlParams {+ url: format!("{}/SKILL.md", server.uri()),+ timeout_secs: Some(5),+ },+ Some(home.path()),+ true,+ )+ .await+ .expect_err("a 429 must fail the install");++ assert!(+ error.starts_with(crate::skills::ops_install::RATE_LIMITED_ERROR_PREFIX),+ "a throttled host must be reported as rate limiting, got: {error}"+ );+ assert!(+ error.contains("42s"),+ "the host's own Retry-After must survive into the message, got: {error}"+ );+}++/// A 429 without a `Retry-After` is still rate limiting — the caller just has+/// no delay to honour. It must not fall through to the generic status string.+#[tokio::test]+async fn a_throttled_host_without_retry_after_still_reports_rate_limiting() {+ use wiremock::matchers::{method, path};+ use wiremock::{Mock, MockServer, ResponseTemplate};++ let server = MockServer::start().await;+ Mock::given(method("GET"))+ .and(path("/SKILL.md"))+ .respond_with(ResponseTemplate::new(429))+ .mount(&server)+ .await;++ let workspace = tempfile::tempdir().unwrap();+ let home = tempfile::tempdir().unwrap();+ let error = install_workflow_from_url_with_home(+ workspace.path(),+ InstallWorkflowFromUrlParams {+ url: format!("{}/SKILL.md", server.uri()),+ timeout_secs: Some(5),+ },+ Some(home.path()),+ true,+ )+ .await+ .expect_err("a 429 must fail the install");++ assert!(+ error.starts_with(crate::skills::ops_install::RATE_LIMITED_ERROR_PREFIX),+ "a 429 with no Retry-After is still rate limiting, got: {error}"+ );+}++/// The other direction: a 404 is a missing skill, not throttling, and must keep+/// the generic status wording. Without this the rate-limit branch could widen+/// to every non-2xx and the distinction would be lost again.+#[tokio::test]+async fn a_missing_skill_is_not_reported_as_rate_limiting() {+ use wiremock::matchers::{method, path};+ use wiremock::{Mock, MockServer, ResponseTemplate};++ let server = MockServer::start().await;+ Mock::given(method("GET"))+ .and(path("/SKILL.md"))+ .respond_with(ResponseTemplate::new(404))+ .mount(&server)+ .await;++ let workspace = tempfile::tempdir().unwrap();+ let home = tempfile::tempdir().unwrap();+ let error = install_workflow_from_url_with_home(+ workspace.path(),+ InstallWorkflowFromUrlParams {+ url: format!("{}/SKILL.md", server.uri()),+ timeout_secs: Some(5),+ },+ Some(home.path()),+ true,+ )+ .await+ .expect_err("a 404 must fail the install");++ assert!(+ !error.starts_with(crate::skills::ops_install::RATE_LIMITED_ERROR_PREFIX),+ "a 404 is a missing skill, not throttling, got: {error}"+ );+ assert!(error.contains("404"), "got: {error}");+}diff --git a/crates/openhuman-core/src/skills/ops_tests.rs b/crates/openhuman-core/src/skills/ops_tests.rsindex d26a5d4944..6033f085a8 100644--- a/crates/openhuman-core/src/skills/ops_tests.rs+++ b/crates/openhuman-core/src/skills/ops_tests.rs@@ -40,5 +40,7 @@ fn make_legacy_skill(ws: &Path, name: &str) -> PathBuf {mod create_and_url_tests;#[path = "ops_discovery_tests.rs"]mod discovery_tests;+#[path = "ops_install_failure_tests.rs"]+mod install_failure_tests;#[path = "ops_uninstall_tests.rs"]mod uninstall_tests;