Skip to content

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

feat(embed): add agent definition module

Steven Enamakelc8bc9b141b59
diff --git a/crates/openhuman-embed/Cargo.toml b/crates/openhuman-embed/Cargo.toml
index 8240910c0b..41a7fa05ba 100644
--- a/crates/openhuman-embed/Cargo.toml
+++ b/crates/openhuman-embed/Cargo.toml
@@ -51,6 +51,8 @@ tinyagents-session = { path = "../../vendor/tinyagents/crates/tinyagents-session
# 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.
+tinytools = { path = "../../vendor/tinyagents/vendor/tinytools/crates/tinytools" }
tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync", "time"] }
url = "2"
uuid = { version = "1", features = ["v4"] }
diff --git a/crates/openhuman-embed/src/agent/definition.rs b/crates/openhuman-embed/src/agent/definition.rs
index c748e2b38b..3c421a9342 100644
--- a/crates/openhuman-embed/src/agent/definition.rs
+++ b/crates/openhuman-embed/src/agent/definition.rs
@@ -45,6 +45,7 @@ pub struct AgentDefinitionSpec {
system_prompt: Option<String>,
tools: Option<ToolScopeSpec>,
disallowed_tools: Vec<String>,
+ tool_rules: Option<tinytools::ToolRules>,
sandbox: SandboxModeSpec,
max_iterations: Option<usize>,
temperature: Option<f64>,
@@ -84,6 +85,15 @@ impl AgentDefinitionSpec {
self
}
+ /// Pattern rules narrowing which tools the agent may see and call — on
+ /// the catalogue, `tool_search` and every call. Stacks with
+ /// [`Self::tools`], [`Self::disallow_tools`] and the runtime config's
+ /// `[tool_rules]`; it can only narrow. See [`tinytools::ToolRules`].
+ pub fn tool_rules(mut self, rules: tinytools::ToolRules) -> Self {
+ self.tool_rules = Some(rules);
+ self
+ }
+
/// Confine the agent's shell and file tools.
pub fn sandbox(mut self, mode: SandboxModeSpec) -> Self {
self.sandbox = mode;
@@ -133,6 +143,9 @@ impl AgentDefinitionSpec {
ToolScopeSpec::Named(names) => ToolScope::Named(names),
};
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 {
SandboxModeSpec::None => SandboxMode::None,
SandboxModeSpec::ReadOnly => SandboxMode::ReadOnly,