Skip to content

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

refactor(tools): introduce anchor point for delegate tools

Steven Enamakela93b423c5c09
diff --git a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
index 45519d2d6f..46a26a5668 100644
--- a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
@@ -35,7 +35,7 @@ pub(crate) fn subagent_prompt_protocol(
/// delegates. Nested spawns would create a recursion tree the harness
/// is not designed to budget, cost, or observe.
///
-/// Matches TinyAgents' spawn-tool list, the host's `delegate` and
+/// Matches TinyAgents' spawn-tool list and the host's
/// `continue_subagent` tools, and every synthesised per-archetype `delegate_*` tool
/// ([`crate::tools::orchestrator_tools::collect_orchestrator_tools`]
/// emits tools for each configured delegation target).
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index 481460bbf4..b5d15c25a5 100644
--- a/crates/openhuman-core/src/tools/ops.rs
+++ b/crates/openhuman-core/src/tools/ops.rs
@@ -433,6 +433,13 @@ pub fn all_tools_with_runtime(
Some(crate::tools::sources::ANCHOR_AFTER_SEARCH),
));
+ // Keep the hosted-tool placement stable for registered sources that still
+ // use the former post-delegate slot.
+ tools.extend(crate::tools::sources::build_registered_tool_sources(
+ &source_ctx,
+ Some(crate::tools::sources::ANCHOR_AFTER_DELEGATE),
+ ));
+
// Hosting tools — deploy a workspace directory through the compiled
// TinyHosts module. Registered only once a credential
// actually resolves (`[hosting].api_key`, else the provider's environment
diff --git a/crates/openhuman-core/src/tools/sources.rs b/crates/openhuman-core/src/tools/sources.rs
index 7fc150fdcf..22daa55472 100644
--- a/crates/openhuman-core/src/tools/sources.rs
+++ b/crates/openhuman-core/src/tools/sources.rs
@@ -47,8 +47,11 @@ pub type ToolSourceFactory =
/// Anchor point: right after the search tools, before hosting.
pub const ANCHOR_AFTER_SEARCH: &str = "after_search";
+/// Stable insertion point for registered hosted tools after the former
+/// configured-delegate catalogue slot and before Composio.
+pub const ANCHOR_AFTER_DELEGATE: &str = "after_delegate";
/// Every anchor `all_tools_with_runtime` splices sources into.
-pub const ANCHORS: [&str; 1] = [ANCHOR_AFTER_SEARCH];
+pub const ANCHORS: [&str; 2] = [ANCHOR_AFTER_SEARCH, ANCHOR_AFTER_DELEGATE];
/// Where in the catalogue a source's tools go.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
diff --git a/crates/openhuman-core/src/tools/sources_tests.rs b/crates/openhuman-core/src/tools/sources_tests.rs
index 2294d3b1ca..0fa3bf8904 100644
--- a/crates/openhuman-core/src/tools/sources_tests.rs
+++ b/crates/openhuman-core/src/tools/sources_tests.rs
@@ -141,9 +141,9 @@ fn anchored_sources_sit_where_the_catalogue_always_listed_them() {
move |_| anchor_tools(&["anchor_fake_search_b"]),
);
register_tool_source_at(
- "test::after_search_extra",
- ToolSourcePlacement::After(ANCHOR_AFTER_SEARCH),
- move |_| anchor_tools(&["anchor_fake_search_extra"]),
+ "test::after_delegate",
+ ToolSourcePlacement::After(ANCHOR_AFTER_DELEGATE),
+ move |_| anchor_tools(&["anchor_fake_delegate"]),
);
register_tool_source("test::end", |_| vec![Box::new(FakeTool("anchor_fake_end"))]);
register_tool_source_at(
@@ -155,7 +155,7 @@ fn anchored_sources_sit_where_the_catalogue_always_listed_them() {
for id in [
"test::after_search_a",
"test::after_search_b",
- "test::after_search_extra",
+ "test::after_delegate",
"test::end",
"test::unknown_anchor",
] {
@@ -176,8 +176,8 @@ fn anchored_sources_sit_where_the_catalogue_always_listed_them() {
assert!(pos("anchor_fake_search_b") < pos("image_info"));
// End sources, and sources with an unknown anchor, trail every built-in
// and keep registration order.
- assert!(pos("image_info") < pos("anchor_fake_search_extra"));
- assert!(pos("anchor_fake_search_extra") < pos("anchor_fake_end"));
+ assert!(pos("image_info") < pos("anchor_fake_delegate"));
+ assert!(pos("anchor_fake_delegate") < pos("anchor_fake_end"));
assert!(pos("anchor_fake_end") < pos("anchor_fake_unknown"));
// Sibling tests register sources on the same process-wide slot, so only
// relative positions are asserted, never the total length.