Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(skills): one discovery pass per workflow lookup, drop anonymous deprecation logs

M3gA-Mind8e166f7810de
diff --git a/src/openhuman/skills/ops_discover.rs b/src/openhuman/skills/ops_discover.rs
index 2778fb9784..29186531e0 100644
--- a/src/openhuman/skills/ops_discover.rs
+++ b/src/openhuman/skills/ops_discover.rs
@@ -126,9 +126,20 @@ pub fn discover_workflows_with_profile(
profile_skills_root: Option<&Path>,
trusted: bool,
) -> Vec<Workflow> {
+ #[cfg(test)]
+ DISCOVERY_CALLS.with(|c| c.set(c.get() + 1));
discover_workflows_inner(home_dir, workspace_dir, profile_skills_root, trusted)
}
+#[cfg(test)]
+thread_local! {
+ /// Test-only counter of full on-disk discovery passes made on this thread.
+ /// Discovery re-reads and re-parses every skill bundle under every root, so
+ /// a caller that runs it twice for one lookup pays the whole tree twice
+ /// (#6166). Thread-local so parallel tests can't perturb each other's count.
+ pub(crate) static DISCOVERY_CALLS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
+}
+
/// Whether the workspace has opted into loading project-scope skills.
///
/// Looks for `<workspace>/.openhuman/trust`. The marker file's contents are
diff --git a/src/openhuman/skills/ops_types.rs b/src/openhuman/skills/ops_types.rs
index 828e0d8926..768e7e3418 100644
--- a/src/openhuman/skills/ops_types.rs
+++ b/src/openhuman/skills/ops_types.rs
@@ -131,7 +131,6 @@ pub(crate) fn extract_version(fm: &WorkflowFrontmatter, warnings: &mut Vec<Strin
return v;
}
if let Some(v) = fm.extra.get("version").and_then(|v| v.as_str()) {
- log::warn!("[skills] top-level 'version' is deprecated; move under 'metadata.version'");
warnings
.push("top-level 'version' is deprecated; move under 'metadata.version'".to_string());
return v.to_string();
@@ -147,7 +146,6 @@ pub(crate) fn extract_author(
return Some(v);
}
if let Some(v) = fm.extra.get("author").and_then(|v| v.as_str()) {
- log::warn!("[skills] top-level 'author' is deprecated; move under 'metadata.author'");
warnings.push("top-level 'author' is deprecated; move under 'metadata.author'".to_string());
return Some(v.to_string());
}
@@ -168,7 +166,6 @@ pub(crate) fn extract_tags(fm: &WorkflowFrontmatter, warnings: &mut Vec<String>)
tags.extend(metadata_string_seq(hermes_tags));
}
if let Some(v) = fm.extra.get("tags") {
- log::warn!("[skills] top-level 'tags' is deprecated; move under 'metadata.tags'");
warnings.push("top-level 'tags' is deprecated; move under 'metadata.tags'".to_string());
tags.extend(metadata_string_seq(v));
}
diff --git a/src/openhuman/skills/registry.rs b/src/openhuman/skills/registry.rs
index 2ace5301f2..b0d4b31492 100644
--- a/src/openhuman/skills/registry.rs
+++ b/src/openhuman/skills/registry.rs
@@ -13,7 +13,7 @@ use std::path::Path;
use serde::{Deserialize, Serialize};
use crate::openhuman::agent::harness::definition::{AgentDefinition, PromptSource};
-use crate::openhuman::skills::WorkflowScope;
+use crate::openhuman::skills::{Workflow, WorkflowScope};
/// One declared input — a parameter the skill needs, with a human description.
/// `required` inputs must be supplied at run time; `kind` is an optional type
@@ -172,6 +172,20 @@ pub fn load_workflows_with_profile(
workspace_dir: &Path,
profile_skills_root: Option<&Path>,
) -> Vec<WorkflowDefinition> {
+ load_workflows_and_discovered(workspace_dir, profile_skills_root).0
+}
+
+/// [`load_workflows_with_profile`] plus the discovered bundles the definitions
+/// were built from.
+///
+/// Discovery re-reads and re-parses every bundle under every root, so a caller
+/// that needs both the runnable definitions and the discovered metadata (scope
+/// and frontmatter `name`, which `WorkflowDefinition` does not carry) takes
+/// them from this one pass instead of running discovery a second time (#6166).
+fn load_workflows_and_discovered(
+ workspace_dir: &Path,
+ profile_skills_root: Option<&Path>,
+) -> (Vec<WorkflowDefinition>, Vec<Workflow>) {
// Prune any legacy bundled skills an older build left behind so discover's
// legacy scan no longer surfaces them (idempotent).
prune_legacy_default_workflows(workspace_dir);
@@ -192,12 +206,13 @@ pub fn load_workflows_with_profile(
// discovery the create/list path uses, then load each one's definition.
let home = dirs::home_dir();
let trusted = super::ops_discover::is_workspace_trusted(workspace_dir);
- for wf in super::ops_discover::discover_workflows_with_profile(
+ let discovered = super::ops_discover::discover_workflows_with_profile(
home.as_deref(),
Some(workspace_dir),
profile_skills_root,
trusted,
- ) {
+ );
+ for wf in &discovered {
let Some(skill_md) = wf.location.as_ref() else {
continue;
};
@@ -222,7 +237,7 @@ pub fn load_workflows_with_profile(
workflows.push(def);
}
}
- workflows
+ (workflows, discovered)
}
/// Build a runnable [`WorkflowDefinition`] from a single workflow directory.
@@ -287,7 +302,7 @@ pub fn get_workflow_with_profile(
id: &str,
profile_skills_root: Option<&Path>,
) -> Option<WorkflowDefinition> {
- let workflows = load_workflows_with_profile(workspace_dir, profile_skills_root);
+ let (workflows, discovered) = load_workflows_and_discovered(workspace_dir, profile_skills_root);
// Built-ins are prepended and discovered workflows follow them. Search in
// reverse so the scope-resolved discovered entry (profile wins over global)
// also wins over a built-in with the same runnable id.
@@ -300,23 +315,19 @@ pub fn get_workflow_with_profile(
// a private workflow admitted by the profile-local allow set can actually
// be described and run. Keep the legacy profile-less lookup id-only: global
// display names have never been runnable ids and may collide with builtins.
- let home = dirs::home_dir();
- let trusted = super::ops_discover::is_workspace_trusted(workspace_dir);
- let slug = super::ops_discover::discover_workflows_with_profile(
- home.as_deref(),
- Some(workspace_dir),
- profile_skills_root,
- trusted,
- )
- .into_iter()
- .find(|workflow| workflow.scope == WorkflowScope::Profile && workflow.name == id)
- .map(|workflow| {
- if workflow.dir_name.is_empty() {
- workflow.name
- } else {
- workflow.dir_name
- }
- })?;
+ //
+ // Answered from the discovery pass already in hand — this used to re-run a
+ // full on-disk discovery and re-parse every bundle a second time (#6166).
+ let slug = discovered
+ .into_iter()
+ .find(|workflow| workflow.scope == WorkflowScope::Profile && workflow.name == id)
+ .map(|workflow| {
+ if workflow.dir_name.is_empty() {
+ workflow.name
+ } else {
+ workflow.dir_name
+ }
+ })?;
workflows
.into_iter()
diff --git a/src/openhuman/skills/registry_tests.rs b/src/openhuman/skills/registry_tests.rs
index a44c23f720..ecc5e61bd9 100644
--- a/src/openhuman/skills/registry_tests.rs
+++ b/src/openhuman/skills/registry_tests.rs
@@ -318,3 +318,47 @@ fn skill_github_config_serializes_lowercase() {
"lowercase serialization: got {s}"
);
}
+
+/// One workflow lookup must run at most one full on-disk discovery pass.
+///
+/// `get_workflow_with_profile` used to discover twice when the id was not an
+/// exact runnable slug: once inside `load_workflows_with_profile`, then again
+/// to resolve a profile display name back to its slug. Discovery re-reads and
+/// re-parses every bundle under every root, so the second pass doubled the cost
+/// — and doubled every per-parse deprecation warning with it (#6166, #6155).
+#[test]
+fn workflow_lookup_discovers_once() {
+ use super::super::ops_discover::DISCOVERY_CALLS;
+
+ let ws = tempfile::TempDir::new().unwrap();
+ let profile_root = tempfile::TempDir::new().unwrap();
+ seed_runnable_with_name(
+ profile_root.path(),
+ "zzcount6166",
+ "Counted Assistant",
+ "COUNT_BODY",
+ );
+
+ // Resolution by display name — the path that took the second pass.
+ DISCOVERY_CALLS.with(|c| c.set(0));
+ let resolved =
+ get_workflow_with_profile(ws.path(), "Counted Assistant", Some(profile_root.path()))
+ .expect("display name must still resolve");
+ assert_eq!(resolved.definition.id, "zzcount6166");
+ assert_eq!(
+ DISCOVERY_CALLS.with(|c| c.get()),
+ 1,
+ "display-name lookup must discover the skills tree once, not twice"
+ );
+
+ // A miss walks the same fallback and must not discover twice either.
+ DISCOVERY_CALLS.with(|c| c.set(0));
+ assert!(
+ get_workflow_with_profile(ws.path(), "zznosuch6166", Some(profile_root.path())).is_none()
+ );
+ assert_eq!(
+ DISCOVERY_CALLS.with(|c| c.get()),
+ 1,
+ "an unresolvable id must discover the skills tree once, not twice"
+ );
+}