Skip to content

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

refactor(prompt): trim withheld intent at word boundary

Steven Enamakel1834d447198e
diff --git a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.rs b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.rs
index 62a499c6a1..d5adae7852 100644
--- a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.rs
+++ b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.rs
@@ -333,7 +333,12 @@ fn first_sentence(text: &str) -> String {
return text.to_string();
}
let cut: String = text.chars().take(WITHHELD_INTENT_MAX_CHARS).collect();
- format!("{}...", cut.trim_end())
+ // Cut at the last word boundary so the row never ends mid-word.
+ let cut = match cut.rfind(' ') {
+ Some(idx) if idx > WITHHELD_INTENT_MAX_CHARS / 2 => &cut[..idx],
+ _ => cut.as_str(),
+ };
+ format!("{}...", cut.trim_end_matches([' ', ',', ';', ':', '-', '—']))
}
/// Render the `## Installed Skills` section listing locally installed
diff --git a/crates/openhuman-core/src/tools/agent_policy/prompt.rs b/crates/openhuman-core/src/tools/agent_policy/prompt.rs
index 3ad964aded..dbd915fa02 100644
--- a/crates/openhuman-core/src/tools/agent_policy/prompt.rs
+++ b/crates/openhuman-core/src/tools/agent_policy/prompt.rs
@@ -24,16 +24,14 @@ pub fn render_tool_policy_boundary(
session.profile.allowed_permission
);
let _ = writeln!(rendered, "- Risk: {}", session.profile.risk_level);
+ // The allowed tools are already on the wire as schemas; listing their
+ // names again here charged every session for a second copy of the belt.
+ // The count keeps the boundary legible without the duplication.
if !session.allowed_tool_names.is_empty() {
let _ = writeln!(
rendered,
- "- Allowed tools: {}",
- session
- .allowed_tool_names
- .iter()
- .map(String::as_str)
- .collect::<Vec<_>>()
- .join(", ")
+ "- Allowed tools: {} (the tools in your list)",
+ session.allowed_tool_names.len()
);
}
let restricted_tool_count = session.restricted_tool_count();
diff --git a/crates/openhuman-core/src/tools/agent_policy/prompt_tests.rs b/crates/openhuman-core/src/tools/agent_policy/prompt_tests.rs
index eaf39068ec..3cc9a7f596 100644
--- a/crates/openhuman-core/src/tools/agent_policy/prompt_tests.rs
+++ b/crates/openhuman-core/src/tools/agent_policy/prompt_tests.rs
@@ -59,7 +59,8 @@ fn render_prompt_boundary_lists_allowed_and_restricted_summary() {
assert!(rendered.contains("## Tool Policy Boundary"));
assert!(rendered.contains("Agent: orchestrator"));
- assert!(rendered.contains("Allowed tools: read_notes"));
+ assert!(rendered.contains("Allowed tools: 1 (the tools in your list)"));
+ assert!(!rendered.contains("read_notes"), "names ride on the schemas, not here");
assert!(rendered.contains("Restricted tools: 1 omitted by policy"));
assert!(!rendered.contains("write_notes"));
}