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(agent): sanitize tool descriptions and fix prompt caching, tool filtering, and tokenization
Steven Enamakel4bc7a11fedda
diff --git a/src/openhuman/agent/debug/wire.rs b/src/openhuman/agent/debug/wire.rsindex 8d5ca20e0a..697265f546 100644--- a/src/openhuman/agent/debug/wire.rs+++ b/src/openhuman/agent/debug/wire.rs@@ -48,7 +48,7 @@ fn thousands(n: usize) -> String {let s = n.to_string();let mut out = String::with_capacity(s.len() + s.len() / 3);for (i, c) in s.chars().enumerate() {- if i > 0 && (s.len() - i).is_multiple_of(3) {+ if i > 0 && (s.len() - i) % 3 == 0 {out.push(',');}out.push(c);diff --git a/src/openhuman/agent/harness/session/builder/factory.rs b/src/openhuman/agent/harness/session/builder/factory.rsindex 063da35b9b..3d807c2627 100644--- a/src/openhuman/agent/harness/session/builder/factory.rs+++ b/src/openhuman/agent/harness/session/builder/factory.rs@@ -983,6 +983,11 @@ impl Agent {.retain(|name| !definition_disallows_tool(&def.disallowed_tools, name));}}+ // Disallowing every tool must remain a zero-tool scope. An+ // empty visible set means "no filter" to the harness.+ if visible.is_empty() {+ visible.insert(NO_TOOLS_SENTINEL.to_string());+ }}}diff --git a/src/openhuman/agent/orchestration/tools/collapsed_delegation.rs b/src/openhuman/agent/orchestration/tools/collapsed_delegation.rsindex a06e37b804..1ba557568b 100644--- a/src/openhuman/agent/orchestration/tools/collapsed_delegation.rs+++ b/src/openhuman/agent/orchestration/tools/collapsed_delegation.rs@@ -133,17 +133,28 @@ fn build_description(targets: &[DelegateTarget]) -> String {);for target in targets {buf.push_str("\n- `");- buf.push_str(&target.tool_name);+ buf.push_str(&prompt_safe(&target.tool_name));buf.push('`');let trimmed = target.description.trim();if !trimmed.is_empty() {buf.push_str(": ");- buf.push_str(trimmed);+ buf.push_str(&prompt_safe(trimmed));}}buf}+fn prompt_safe(value: &str) -> String {+ value+ .chars()+ .map(|ch| match ch {+ '`' => '\'',+ ch if ch.is_control() => ' ',+ ch => ch,+ })+ .collect()+}+#[async_trait]impl Tool for CollapsedDelegationTool {fn name(&self) -> &str {diff --git a/src/openhuman/agent/prompts/sections.rs b/src/openhuman/agent/prompts/sections.rsindex 3d13b50ff8..7ebbfd53fe 100644--- a/src/openhuman/agent/prompts/sections.rs+++ b/src/openhuman/agent/prompts/sections.rs@@ -643,8 +643,8 @@ impl PromptSection for UserMemorySection {impl PromptSection for DateTimeSection {fn tier(&self) -> PromptTier {- // The clock. Nothing emitted after this can ever be cached.- PromptTier::Volatile+ // The live clock is carried in the user message. This section is static.+ PromptTier::Stable}fn name(&self) -> &str {diff --git a/src/openhuman/flows/agents/workflow_builder/prompt.md b/src/openhuman/flows/agents/workflow_builder/prompt.mdindex 5e7363f651..d2c1732e57 100644--- a/src/openhuman/flows/agents/workflow_builder/prompt.md+++ b/src/openhuman/flows/agents/workflow_builder/prompt.md@@ -186,7 +186,7 @@ rather than a general context recall), use `memory_hybrid_search` in itsYou have a machine-readable belt; use it instead of relying on memory:-- **Introspect the DSL:** `list_node_kinds` → the 14 kinds; `get_node_kind_contract+- **Introspect the DSL:** `list_node_kinds` → the 22 kinds; `get_node_kind_contract{ kind }` → one kind's exact config fields, ports, an example, and itsgotchas. Consult these instead of guessing config shapes (this is the sourceof truth; the summary below is just orientation).@@ -666,8 +666,7 @@ rather wait one more tool call than review a graph that silently doesnothing. **One exception:** a `null_resolutions` entry flagged `unverifiable:true` (or an `unverifiable_bindings` list) is a Composio-upstream binding thesandbox genuinely can't check — confirm it with `get_tool_contract` rather-than re-wiring, and don't loop on it (see "Interpreting dry-run results-honestly" below).+than re-wiring, and don't loop on it.### Say what you inferreddiff --git a/src/openhuman/util/bm25.rs b/src/openhuman/util/bm25.rsindex fa7a78e949..687edd1785 100644--- a/src/openhuman/util/bm25.rs+++ b/src/openhuman/util/bm25.rs@@ -63,7 +63,7 @@ pub fn tokenize(text: &str) -> Vec<String> {if ch.is_uppercase() && previous_lower && !current.is_empty() {out.push(std::mem::take(&mut current));}- current.push(ch.to_ascii_lowercase());+ current.extend(ch.to_lowercase());previous_lower = ch.is_lowercase() || ch.is_numeric();} else if !current.is_empty() {out.push(std::mem::take(&mut current));