Skip to content

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

fix(agent): trim long service blurbs in delegation description

Steven Enamakelcb91a9e12b3f
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/skill_delegation.rs b/crates/openhuman-core/src/agent/orchestration/tools/skill_delegation.rs
index d4bc4c7a56..7772f2c3d3 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/skill_delegation.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/skill_delegation.rs
@@ -62,21 +62,31 @@ impl SkillDelegationTool {
}
fn build_description(connected: &[(String, String)]) -> String {
- // The slugs are already the `toolkit` enum; naming them again with their
- // marketing blurb cost a line per connected service on every turn. One
- // sentence of routing plus the slug list is what the model needs.
+ // One sentence of routing plus one short line per connected service. The
+ // catalogue blurbs are marketing copy ("Gmail is Google's email service,
+ // featuring spam protection, ...") and were costing a paragraph per
+ // service on every turn; a clause is enough to disambiguate a slug.
+ const DESCRIPTION_MAX_CHARS: usize = 80;
let mut buf = String::from(
"Act on a connected service (read or write its data) through the integrations \
- agent, with `toolkit` set to one of the connected slugs and the user's task as \
- `prompt`. Connected:",
+ agent: `toolkit` is one of the connected slugs below, `prompt` the user's task. \
+ Connected:",
);
- for (slug, _desc) in connected {
- buf.push(' ');
+ for (slug, desc) in connected {
+ buf.push_str("\n - ");
buf.push_str(slug);
- buf.push(',');
- }
- if buf.ends_with(',') {
- buf.pop();
+ let trimmed = desc.trim();
+ if !trimmed.is_empty() {
+ buf.push_str(": ");
+ if trimmed.chars().count() > DESCRIPTION_MAX_CHARS {
+ let cut: String = trimmed.chars().take(DESCRIPTION_MAX_CHARS).collect();
+ let cut = cut.rsplit_once(' ').map_or(cut.as_str(), |(head, _)| head);
+ buf.push_str(cut.trim_end_matches([',', ';', ':']));
+ buf.push_str("...");
+ } else {
+ buf.push_str(trimmed);
+ }
+ }
}
buf
}
diff --git a/crates/openhuman-core/src/tools/orchestrator_tools_tests.rs b/crates/openhuman-core/src/tools/orchestrator_tools_tests.rs
index 85cdef405c..7cc942d216 100644
--- a/crates/openhuman-core/src/tools/orchestrator_tools_tests.rs
+++ b/crates/openhuman-core/src/tools/orchestrator_tools_tests.rs
@@ -113,7 +113,7 @@ fn collects_agentid_entries_and_collapses_skills_wildcard() {
// Archetype tool descriptions come from `when_to_use`.
let research_tool = tools.iter().find(|t| t.name() == "research").unwrap();
- assert!(research_tool.description().contains("crawler"));
+ assert!(research_tool.description().contains("crawler"), "delegate description is the target's when_to_use");
// The collapsed delegation tool enumerates every connected toolkit
// in its description so the orchestrator still discovers what's