Skip to content

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

refactor(toolpacks): move use_skill tests and helpers into tinyagents_harness

Steven Enamakel7116149c3651
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/artifact_index_toc.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/artifact_index_toc.rs
index dbe4ddef36..4d1117e2bc 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/artifact_index_toc.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/artifact_index_toc.rs
@@ -84,7 +84,7 @@ pub(crate) fn split_input_allowance(trim_allowance: u64) -> (u64, u64) {
/// lost the ability to reach its own findings. No log fires, because nothing
/// failed.
///
-/// The index has been maintained all along (`ToolResultArtifactIndexStore`,
+/// The index has been maintained all along (`InMemoryStore` (the index),
/// registered on `RunContext.stores`, written on every persist). Nothing read
/// it. This reads it.
///
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_tests.rs
index d7e1b5551b..ab7a06ee9a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_tests.rs
@@ -14,7 +14,7 @@ async fn same_tool_calls_persist_artifacts_under_distinct_call_ids() {
let middleware = ToolOutputMiddleware {
budget_bytes: 8,
payload_summarizer: None,
- artifact_store: Some(ToolResultArtifactStore::new(
+ artifact_store: Some(crate::agent::harness::tool_result_artifacts::new_tool_result_store(
temp.path().to_path_buf(),
"identity-session",
)),
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_artifact_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_artifact_tests.rs
index c37b3d39a6..d79549a377 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_artifact_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_artifact_tests.rs
@@ -12,7 +12,7 @@ fn artifact_mw(
budget_bytes: 1_000,
payload_summarizer: summarizer,
artifact_store: Some(
- crate::agent::harness::tool_result_artifacts::ToolResultArtifactStore::new(
+ crate::agent::harness::tool_result_artifacts::new_tool_result_store(
action_dir.to_path_buf(),
"session",
),
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs
index d34732731b..97cf016c81 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs
@@ -13,7 +13,8 @@ use crate::tools::agent_policy::{
TaskProfile, TaskRiskLevel, ToolCapability, ToolPolicyAction, ToolPolicyDecision,
ToolPolicySession,
};
-use crate::tools::toolpacks::{append_pack_tools, bind_pack_registry, USE_SKILL};
+use crate::tools::toolpacks::{append_pack_tools, bind_pack_registry};
+use tinyagents_harness::tool::packs::USE_SKILL;
use tinytools::{PermissionLevel, ToolResult};
struct RoutingFakeTool(&'static str);
diff --git a/crates/openhuman-core/src/agent/tinyagents/use_skill_dispatch_tests.rs b/crates/openhuman-core/src/agent/tinyagents/use_skill_dispatch_tests.rs
index 59489fb4c1..f4371aec4b 100644
--- a/crates/openhuman-core/src/agent/tinyagents/use_skill_dispatch_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/use_skill_dispatch_tests.rs
@@ -178,7 +178,7 @@ fn parent_execution_context(workspace_dir: &Path) -> ParentExecutionContext {
/// wrapping `use_skill` that the harness would have registered.
fn build_use_skill_dispatch() -> UseSkillDispatch {
let handle = PackRegistryHandle::default();
- let use_skill_tool: Box<dyn Tool> = Box::new(UseSkillTool::new(handle.clone()));
+ let use_skill_tool: Box<dyn Tool> = Box::new(UseSkillTool::new(handle.clone(), crate::tools::toolpacks::CATALOG));
let create_image_tool: Box<dyn Tool> = Box::new(StubCreateImage);
let durable: Arc<Vec<Box<dyn Tool>>> = Arc::new(vec![use_skill_tool, create_image_tool]);
handle.bind(Arc::downgrade(&durable));
diff --git a/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests.rs b/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests.rs
index 54730fb0a3..c4c755556b 100644
--- a/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests.rs
+++ b/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests.rs
@@ -11,6 +11,7 @@ use async_trait::async_trait;
use serde_json::{json, Value};
use super::*;
+use tinyagents_harness::tool::packs::USE_SKILL;
use tinytools::{PermissionLevel, Tool, ToolResult, ToolTimeout};
struct FakeTool {
@@ -78,20 +79,6 @@ fn registry_with(name: &'static str, level: PermissionLevel) -> Arc<Vec<Box<dyn
tools
}
-/// A registry whose one packed tool is externally effectful and unbounded.
-fn external_unbounded_registry(name: &'static str) -> Arc<Vec<Box<dyn Tool>>> {
- let mut tools: Vec<Box<dyn Tool>> = vec![Box::new(FakeTool {
- name,
- level: PermissionLevel::ReadOnly,
- external: true,
- timeout: ToolTimeout::Unbounded,
- })];
- append_pack_tools(&mut tools);
- let tools = Arc::new(tools);
- bind_pack_registry(&tools);
- tools
-}
-
fn find<'a>(tools: &'a [Box<dyn Tool>], name: &str) -> &'a dyn Tool {
tools
.iter()
@@ -279,32 +266,6 @@ async fn use_skill_without_a_tool_renders_the_schema_of_a_present_tool() {
);
}
-#[tokio::test]
-async fn use_skill_rejects_an_unknown_skill() {
- let tools = registry_with("manage_tasks", PermissionLevel::ReadOnly);
- let result = find(&tools, USE_SKILL)
- .execute(json!({"skill": "nope"}))
- .await
- .unwrap();
- assert!(result.is_error);
-}
-
-#[tokio::test]
-async fn use_skill_dispatches_to_the_packed_tool() {
- let name = pack("web3").unwrap().tools[0];
- let tools = registry_with(name, PermissionLevel::ReadOnly);
- let result = find(&tools, USE_SKILL)
- .execute(json!({"skill": "web3", "tool": name, "args": {"marker": "x"}}))
- .await
- .unwrap();
- assert!(!result.is_error);
- let text = format!("{:?}", result.content);
- assert!(
- text.contains("marker"),
- "inner args were not forwarded: {text}"
- );
-}
-
#[tokio::test]
async fn use_skill_refuses_a_tool_from_another_skill() {
// Cross-skill dispatch would make the `skill` argument decoration and let a
@@ -331,86 +292,6 @@ fn use_skill_reports_the_inner_tools_permission_level() {
);
}
-#[test]
-fn naming_no_tool_is_read_only_even_when_the_pack_is_dangerous() {
- // The disclosure branch renders a schema and does nothing else. Reporting
- // the packed ceiling here would put an approval prompt in front of reading
- // a tool list, which is the round trip merging the two tools removed.
- let name = pack("web3").unwrap().tools[0];
- let tools = registry_with(name, PermissionLevel::Dangerous);
- let use_skill = find(&tools, USE_SKILL);
- assert_eq!(
- use_skill.permission_level_with_args(&json!({"skill": "web3"})),
- PermissionLevel::ReadOnly
- );
- // An empty string is a named-nothing call, not a tool called "".
- assert_eq!(
- use_skill.permission_level_with_args(&json!({"skill": "web3", "tool": ""})),
- PermissionLevel::ReadOnly
- );
- // Naming a real one still reports that tool's level, not this branch's.
- assert_eq!(
- use_skill.permission_level_with_args(&json!({"skill": "web3", "tool": name})),
- PermissionLevel::Dangerous
- );
-}
-
-#[test]
-fn use_skill_forwards_the_inner_tools_external_effect() {
- // The approval gate calls external_effect_with_args on the proxy; a proxy
- // that reported false would let an effectful packed tool skip the prompt.
- let name = pack("web3").unwrap().tools[0];
- let tools = external_unbounded_registry(name);
- let use_skill = find(&tools, USE_SKILL);
- assert!(
- use_skill.external_effect_with_args(&json!({"skill": "web3", "tool": name})),
- "proxy must forward the inner tool's external-effect classification"
- );
-}
-
-#[test]
-fn use_skill_forwards_the_inner_tools_timeout_policy() {
- // A packed scripting tool must run under its own deadline, not the proxy's.
- let name = pack("web3").unwrap().tools[0];
- let tools = external_unbounded_registry(name);
- let use_skill = find(&tools, USE_SKILL);
- assert_eq!(
- use_skill.timeout_policy(&json!({"skill": "web3", "tool": name})),
- ToolTimeout::Unbounded
- );
-}
-
-#[test]
-fn an_unresolvable_call_reports_inherit_timeout() {
- let name = pack("web3").unwrap().tools[0];
- let tools = external_unbounded_registry(name);
- let use_skill = find(&tools, USE_SKILL);
- assert_eq!(
- use_skill.timeout_policy(&json!({"skill": "web3", "tool": "nonexistent"})),
- ToolTimeout::Inherit
- );
-}
-
-#[test]
-fn an_unresolvable_call_reports_the_ceiling_not_a_permissive_default() {
- let name = pack("web3").unwrap().tools[0];
- let tools = registry_with(name, PermissionLevel::Dangerous);
- let use_skill = find(&tools, USE_SKILL);
- assert_eq!(
- use_skill.permission_level_with_args(&json!({"skill": "web3", "tool": "nonexistent"})),
- PermissionLevel::Dangerous
- );
-}
-
-#[test]
-fn an_unbound_handle_degrades_closed() {
- // A pack tool that never got bound must not become a permissive passthrough.
- let mut tools: Vec<Box<dyn Tool>> = Vec::new();
- append_pack_tools(&mut tools);
- let use_skill = find(&tools, USE_SKILL);
- assert_eq!(use_skill.permission_level(), PermissionLevel::Dangerous);
-}
-
#[test]
fn every_pack_declares_the_tools_it_is_named_for() {
// Membership is compiled-in data, so a typo here is invisible until a
diff --git a/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_scoping_and_visibility_tests.rs b/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_scoping_and_visibility_tests.rs
index da1e7fe1d0..39d306dff4 100644
--- a/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_scoping_and_visibility_tests.rs
+++ b/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_scoping_and_visibility_tests.rs
@@ -2,6 +2,7 @@
//! execution distinction the whole pack mechanism rests on.
use super::*;
+use tinyagents_harness::tool::packs::{route_sentence, USE_SKILL};
// ── the index must agree with the gate too ──────────────────────────────────
@@ -30,7 +31,7 @@ fn the_index_drops_a_pack_this_session_can_call_nothing_in() {
// Only the workflows pack is reachable.
let workflows = pack("workflows").expect("workflows pack");
- let kept = scope_use_skill_spec(&mut spec, &|name| workflows.tools.contains(&name));
+ let kept = tinyagents_harness::tool::packs::scope_use_skill_spec(&CATALOG, &mut spec, &|name| workflows.tools.contains(&name));
assert!(
kept,
"workflows is callable, so use_skill stays on the wire"
@@ -56,7 +57,7 @@ fn the_index_drops_a_pack_this_session_can_call_nothing_in() {
fn the_skill_enum_offers_only_reachable_packs() {
let mut spec = use_skill_spec();
let workflows = pack("workflows").expect("workflows pack");
- scope_use_skill_spec(&mut spec, &|name| workflows.tools.contains(&name));
+ tinyagents_harness::tool::packs::scope_use_skill_spec(&CATALOG, &mut spec, &|name| workflows.tools.contains(&name));
let values = spec
.parameters
@@ -79,7 +80,7 @@ fn the_skill_enum_offers_only_reachable_packs() {
fn a_session_that_can_reach_no_pack_loses_use_skill() {
let mut spec = use_skill_spec();
assert!(
- !scope_use_skill_spec(&mut spec, &|_| false),
+ !tinyagents_harness::tool::packs::scope_use_skill_spec(&CATALOG, &mut spec, &|_| false),
"with nothing reachable, use_skill must be dropped, not emptied"
);
}
@@ -91,7 +92,7 @@ fn scoping_the_index_only_ever_shrinks_it() {
let mut spec = use_skill_spec();
let before = spec.description.len();
let workflows = pack("workflows").expect("workflows pack");
- scope_use_skill_spec(&mut spec, &|name| workflows.tools.contains(&name));
+ tinyagents_harness::tool::packs::scope_use_skill_spec(&CATALOG, &mut spec, &|name| workflows.tools.contains(&name));
assert!(
spec.description.len() < before,
"scoped index ({}) must be smaller than the full one ({before})",
@@ -236,7 +237,7 @@ fn a_non_owner_listing_omits_the_tools_the_gate_will_refuse() {
let handle = crate::tools::host_extensions::pack_registry_handle(find(&tools, USE_SKILL))
.expect("use_skill carries the pack handle");
- let rendered = render_pack_filtered(
+ let rendered = tinyagents_harness::tool::packs::render_pack_filtered(&CATALOG,
"workflows",
handle,
&|name: &str| name != "propose_workflow",
@@ -263,7 +264,7 @@ fn a_listing_with_nothing_callable_names_the_route_out() {
.expect("use_skill carries the pack handle");
let route = route_sentence(&["build_workflow".to_string()], &["workflow_builder"]);
- let err = render_pack_filtered("workflows", handle, &|_| false, &route)
+ let err = tinyagents_harness::tool::packs::render_pack_filtered(&CATALOG, "workflows", handle, &|_| false, &route)
.expect_err("nothing callable must not render a menu");
assert!(
@@ -272,27 +273,6 @@ fn a_listing_with_nothing_callable_names_the_route_out() {
);
}
-/// Naming the tool, not just the agent, is the difference between an
-/// instruction and a guess — and a model that guesses wrong retries.
-#[test]
-fn route_sentence_prefers_a_callable_tool_and_falls_back_to_owners() {
- let named = route_sentence(&["build_workflow".to_string()], &["workflow_builder"]);
- assert!(named.contains("`build_workflow`"), "{named}");
- assert!(
- !named.contains("`workflow_builder`"),
- "naming the agent as well is noise once the call is named: {named}"
- );
-
- let fallback = route_sentence(&[], &["workflow_builder", "flow_discovery"]);
- assert!(fallback.contains("`workflow_builder`"), "{fallback}");
- assert!(fallback.contains("`flow_discovery`"), "{fallback}");
-
- assert!(
- route_sentence(&[], &[]).is_empty(),
- "an ownerless pack has no route to offer and must stay silent"
- );
-}
-
/// The route only exists because these owners do. If the `workflows` pack is
/// ever re-owned, the hint silently stops naming `workflow_builder` — this
/// pins the assumption the two tests above rest on.
diff --git a/tests/raw_coverage/tools_erased_host_extension_raw_coverage_e2e.rs b/tests/raw_coverage/tools_erased_host_extension_raw_coverage_e2e.rs
index d02bede6b7..c4f0f4bfeb 100644
--- a/tests/raw_coverage/tools_erased_host_extension_raw_coverage_e2e.rs
+++ b/tests/raw_coverage/tools_erased_host_extension_raw_coverage_e2e.rs
@@ -31,7 +31,7 @@ use openhuman_core::agent::tool_policy::{
GeneratedToolRuntimeContext, GeneratedToolRuntimeRisk,
};
use openhuman_core::skills::types::tool_result_from_mcp;
-use openhuman_core::tools::toolpacks::registry::PACKS;
+use openhuman_core::tools::toolpacks::registry::{CATALOG, PACKS};
use tinyagents_harness::tool::packs::{PackRegistryHandle, UseSkillTool};
use openhuman_core::tools::host_extensions::{generated_runtime_context, pack_registry_handle};
use tinytools::{PermissionLevel, Tool, ToolResult};
@@ -65,7 +65,7 @@ use tinytools::{PermissionLevel, Tool, ToolResult};
/// observed without needing to construct a real packed tool.
#[tokio::test]
async fn a_pack_tools_registry_handle_reads_back_as_the_same_handle() {
- let tool = UseSkillTool::new(PackRegistryHandle::default());
+ let tool = UseSkillTool::new(PackRegistryHandle::default(), CATALOG);
let recovered = pack_registry_handle(&tool).expect(
"a pack tool must yield its PackRegistryHandle through the erased \