Skip to content

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

test(debug): cover integration tool protocol rendering

Steven Enamakel3b6820a59099
diff --git a/crates/openhuman-core/src/agent/debug/debug_protocol_tests.rs b/crates/openhuman-core/src/agent/debug/debug_protocol_tests.rs
new file mode 100644
index 0000000000..5fff3c979c
--- /dev/null
+++ b/crates/openhuman-core/src/agent/debug/debug_protocol_tests.rs
@@ -0,0 +1,15 @@
+use super::*;
+
+#[test]
+fn text_mode_dispatcher_instructions_follow_the_available_catalogue() {
+ assert!(text_mode_dispatcher_instructions(&[]).is_empty());
+
+ let schema = tinyinference_llm::tool::ToolSchema::new(
+ "calendar_search",
+ "Search calendar events.",
+ serde_json::json!({"type": "object", "properties": {}}),
+ );
+ let instructions = text_mode_dispatcher_instructions(&[schema]);
+ assert!(instructions.contains("## Tool Use Protocol"));
+ assert!(instructions.contains("calendar_search"));
+}
diff --git a/crates/openhuman-core/src/agent/debug/mod.rs b/crates/openhuman-core/src/agent/debug/mod.rs
index c23b4bdf45..0d484a29e5 100644
--- a/crates/openhuman-core/src/agent/debug/mod.rs
+++ b/crates/openhuman-core/src/agent/debug/mod.rs
@@ -492,11 +492,7 @@ async fn render_integrations_agent(config: &Config, toolkit: &str) -> Result<Dum
)
})
.collect();
- let dispatcher_instructions = if text_mode_schemas.is_empty() {
- String::new()
- } else {
- tinyagents_harness::tool::prompt_tool_instructions(&text_mode_schemas)
- };
+ let dispatcher_instructions = text_mode_dispatcher_instructions(&text_mode_schemas);
let ctx = PromptContext {
workspace_dir: agent.workspace_dir(),
model_name: &model_name,
@@ -544,6 +540,20 @@ async fn render_integrations_agent(config: &Config, toolkit: &str) -> Result<Dum
})
}
+/// Render the text-mode protocol only when the integrations agent has tools.
+/// An empty catalogue must not invite the model to make an unavailable call.
+fn text_mode_dispatcher_instructions(schemas: &[tinyinference_llm::tool::ToolSchema]) -> String {
+ if schemas.is_empty() {
+ String::new()
+ } else {
+ tinyagents_harness::tool::prompt_tool_instructions(schemas)
+ }
+}
+
+#[cfg(test)]
+#[path = "debug_protocol_tests.rs"]
+mod protocol_tests;
+
/// Wrap a `&dyn Tool` as a `Box<dyn Tool>` proxy that forwards
/// `name()` / `description()` / `parameters_schema()` / `category()`
/// — enough surface for prompt rendering. `execute` is intentionally