Skip to content

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

Merge remote-tracking branch 'upstream/main' into tool-rules

Steven Enamakeldcde8d649694
diff --cc crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
index 9b1ccc280b,bc3cedde87..c16a7200d6
--- a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
@@@ -296,8 -296,8 +296,9 @@@ pub(super) async fn run_turn_via_tinyag
),
has_thread,
run_context.memory_turn.clone(),
+ run_context.tool_rules.clone(),
);
+ super::response_shape::install(&mut harness, hosted_root.is_some());
// Fail-closed registry validation gate (issue #4249, Workstream 10 — registry).
// The projected `CapabilityRegistry` produced these diagnostics during
diff --cc crates/openhuman-embed/Cargo.toml
index 905037430a,105e942704..b26e81c8b8
--- a/crates/openhuman-embed/Cargo.toml
+++ b/crates/openhuman-embed/Cargo.toml
@@@ -55,7 -60,8 +60,9 @@@ tinyagents-session = { path = "../../ve
# core's so one copy resolves.
tinyinference-llm = { path = "../../vendor/tinyagents/vendor/tinyinference/crates/tinyinference-llm" }
tinyinference-embeddings = { path = "../../vendor/tinyagents/vendor/tinyinference/crates/tinyinference-embeddings" }
- # `AgentDefinitionSpec::tool_rules` takes the shared tool-rule vocabulary.
+ # `RuntimeBuilder::tool_ranker` takes `tinytools::ToolRanker`; same vendored
+ # path as the core's so the trait unifies.
++# `AgentDefinitionSpec::tool_rules` takes the shared tool-rule vocabulary too.
tinytools = { path = "../../vendor/tinyagents/vendor/tinytools/crates/tinytools" }
tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync", "time"] }
url = "2"
diff --cc crates/openhuman-embed/src/agent/definition.rs
index 3c421a9342,6e5d611506..fb3f7442a6
--- a/crates/openhuman-embed/src/agent/definition.rs
+++ b/crates/openhuman-embed/src/agent/definition.rs
@@@ -43,9 -55,10 +55,11 @@@ pub enum SandboxModeSpec
#[derive(Debug, Clone, Default)]
pub struct AgentDefinitionSpec {
system_prompt: Option<String>,
+ /// The prompt is the whole system prompt, with nothing composed around it.
+ bare_prompt: bool,
tools: Option<ToolScopeSpec>,
disallowed_tools: Vec<String>,
+ tool_rules: Option<tinytools::ToolRules>,
sandbox: SandboxModeSpec,
max_iterations: Option<usize>,
temperature: Option<f64>,
@@@ -141,12 -180,12 +190,15 @@@ impl AgentDefinitionSpec
def.tools = match self.tools.unwrap_or(ToolScopeSpec::Wildcard) {
ToolScopeSpec::Wildcard => ToolScope::Wildcard,
ToolScopeSpec::Named(names) => ToolScope::Named(names),
+ // Zero tools; the host's names join at session build.
+ ToolScopeSpec::HostOnly => ToolScope::Named(Vec::new()),
};
def.disallowed_tools.extend(self.disallowed_tools);
+ if let Some(rules) = self.tool_rules {
+ def.tool_rules = Some(rules);
+ }
def.sandbox_mode = match self.sandbox {
+ _ if host_only => SandboxMode::ReadOnly,
SandboxModeSpec::None => SandboxMode::None,
SandboxModeSpec::ReadOnly => SandboxMode::ReadOnly,
SandboxModeSpec::Sandboxed => SandboxMode::Sandboxed,
diff --cc crates/openhuman-embed/src/agent/definition_tests.rs
index 576ed4f397,d1e6c59f30..4459156ca5
--- a/crates/openhuman-embed/src/agent/definition_tests.rs
+++ b/crates/openhuman-embed/src/agent/definition_tests.rs
@@@ -35,17 -35,44 +35,59 @@@ fn setters_override_one_aspect_each()
assert_eq!(def.display_name(), "Alpha");
}
+ #[test]
+ fn bare_prompt_is_verbatim_with_nothing_composed_around_it() {
+ let def = AgentDefinitionSpec::new()
+ .bare_prompt("Review.")
+ .into_core("alpha")
+ .expect("definition");
+ assert!(matches!(def.system_prompt, PromptSource::Verbatim(ref p) if p == "Review."));
+ assert!(def.omit_identity && def.omit_safety_preamble && def.omit_memory_context);
+ }
+
+ #[test]
+ fn system_prompt_after_bare_prompt_is_wrapped_again() {
+ let def = AgentDefinitionSpec::new()
+ .bare_prompt("Review.")
+ .system_prompt("Be terse.")
+ .into_core("alpha")
+ .expect("definition");
+ assert!(matches!(def.system_prompt, PromptSource::Inline(ref p) if p == "Be terse."));
+ }
+
+ #[test]
+ fn host_only_is_an_empty_read_only_belt_that_cannot_delegate() {
+ let def = AgentDefinitionSpec::new()
+ .bare_prompt("Review.")
+ .tools(ToolScopeSpec::HostOnly)
+ .sandbox(SandboxModeSpec::None)
+ .into_core("alpha")
+ .expect("definition");
+ assert!(matches!(def.tools, ToolScope::Named(ref names) if names.is_empty()));
+ assert_eq!(def.sandbox_mode, SandboxMode::ReadOnly);
+ assert!(def.subagents.is_empty());
+ }
+
+ #[test]
+ fn host_only_without_a_prompt_is_refused() {
+ let err = AgentDefinitionSpec::new()
+ .tools(ToolScopeSpec::HostOnly)
+ .into_core("alpha")
+ .expect_err("the orchestrator prompt does not describe a host-only agent");
+ assert!(matches!(err, AgentError::Invalid(_)));
+ }
++
+#[test]
+fn tool_rules_reach_the_core_definition() {
+ let rules = tinytools::ToolRules::from_allow_deny(Vec::<String>::new(), ["mcp_*"]);
+ let def = AgentDefinitionSpec::new()
+ .tool_rules(rules.clone())
+ .into_core("narrow")
+ .unwrap();
+ assert_eq!(def.tool_rules, Some(rules));
+ assert!(AgentDefinitionSpec::new()
+ .into_core("open")
+ .unwrap()
+ .tool_rules
+ .is_none());
+}
diff --cc scripts/ci/check-openhuman-rust-layout.mjs
index fa2595d069,cf3c9a9005..0867dd3e40
--- a/scripts/ci/check-openhuman-rust-layout.mjs
+++ b/scripts/ci/check-openhuman-rust-layout.mjs
@@@ -43,9 -43,9 +43,9 @@@ const LEGACY_LIMIT_ENTRIES =
// provider, security, memory, tool and prompt policy. Generic session
// state moved to tinyagents-runtime; this remaining composition is split in
// a follow-up without reintroducing an old harness/session exception.
- ["crates/openhuman-core/src/agent/session_host/builder/factory.rs", 984],
+ ["crates/openhuman-core/src/agent/session_host/builder/factory.rs", 977],
["crates/openhuman-core/src/agent/subagent_host/lifecycle.rs", 1309],
- ["crates/openhuman-core/src/agent/subagent_host/ops/runner.rs", 1151],
+ ["crates/openhuman-core/src/agent/subagent_host/ops/runner.rs", 1150],
["crates/openhuman-core/src/tools/ops.rs", 1209],
["crates/openhuman-core/src/web_chat/progress_bridge.rs", 1304],
// These established external test modules grew with upstream coverage. Pin