Skip to content

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

feat(agent): add bridge prompt tools for text dialect tool discovery

Steven Enamakelc830a4397b82
diff --git a/crates/openhuman-core/src/agent/tinyagents/discovery/mod.rs b/crates/openhuman-core/src/agent/tinyagents/discovery/mod.rs
index f77dafa80d..a0126104ba 100644
--- a/crates/openhuman-core/src/agent/tinyagents/discovery/mod.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/discovery/mod.rs
@@ -122,6 +122,49 @@ pub(crate) fn discovery_policy() -> ToolDiscoveryPolicy {
policy
}
+/// The `tool_search` / `tool_call` bridge, rendered for a TEXT dialect's
+/// prompt catalogue.
+///
+/// The harness mints these two schemas onto `request.tools` whenever a run
+/// has a deferred catalogue, which is all a native-tool-calling provider
+/// needs. A text dialect (P-Format / code) never sees that set: the dialect
+/// folds the catalogue into the system prompt and clears `request.tools`,
+/// and because OpenHuman sets `host_renders_tool_catalogue` the harness
+/// appends nothing of its own. So on those dialects the bridge only reaches
+/// the model if the host's own catalogue carries it — otherwise the model
+/// reads "invoke a match with `tool_call`" in a search result naming a tool
+/// no signature in its catalogue describes, and answers with intent instead
+/// of a call.
+///
+/// Built from [`tinyagents_harness::tool::discover::bridge_schemas`] rather
+/// than hand-written prose, so the signature the model reads is the one
+/// admission accepts. `deferred` only sizes the placeholder catalogue the
+/// manifest is rendered from; the per-tool manifest itself is deliberately
+/// left out of the prompt, because listing every deferred tool there is the
+/// cost deferral exists to avoid.
+pub(crate) fn bridge_prompt_tools(deferred: usize) -> Vec<crate::agent::prompts::PromptTool<'static>>
+{
+ if deferred == 0 {
+ return Vec::new();
+ }
+ use tinyagents_harness::tool::discover::{bridge_schemas, DeferredCatalog};
+ let mut policy = discovery_policy();
+ // A zero budget renders the manifest as a bare count instead of naming
+ // every deferred tool — the prompt advertises that a search exists, not
+ // what it would find.
+ policy.manifest_token_budget = 0;
+ bridge_schemas(&DeferredCatalog::build(Vec::new()), &policy)
+ .into_iter()
+ .map(|schema| {
+ crate::agent::prompts::PromptTool::owned(
+ schema.name,
+ schema.description,
+ schema.parameters.to_string(),
+ )
+ })
+ .collect()
+}
+
/// The verb-gated token-overlap ranker the Composio sub-agent narrows its
/// toolkit with (`tinyagents_harness::tool::select::rank_tools_by_prompt`),
/// behind the [`ToolRanker`] trait so it can be installed, compared, or