Skip to content

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

chore: Let me analyze this diff carefully.

Steven Enamakel5ad8c17c9ca1
diff --git a/src/openhuman/agent/harness/session/turn/context.rs b/src/openhuman/agent/harness/session/turn/context.rs
index 91068a0f81..4323fe8c6d 100644
--- a/src/openhuman/agent/harness/session/turn/context.rs
+++ b/src/openhuman/agent/harness/session/turn/context.rs
@@ -281,10 +281,22 @@ impl Agent {
/// instructions and learned context.
pub fn build_system_prompt(&self, learned: LearnedContextData) -> Result<String> {
let tools_slice: &[Box<dyn Tool>] = self.tools.as_slice();
+ // `visible_tool_specs` holds shared `Arc<ToolSpec>` leaves (they are the
+ // same schema objects the durable and full views point at), while the
+ // `ToolDispatcher` trait — which embedders implement — takes an owned
+ // `&[ToolSpec]`. Materialise a borrow-slice for the call: this is one
+ // transient copy per system-prompt build, not a per-agent resident one,
+ // and keeping it here is what lets the trait stay source-compatible.
+ let visible_specs_owned: Vec<ToolSpec> = self
+ .visible_tool_specs
+ .iter()
+ .map(|spec| spec.as_ref().clone())
+ .collect();
let instructions = self
.tool_dispatcher
- .prompt_instructions_for_specs(self.visible_tool_specs.as_slice())
+ .prompt_instructions_for_specs(&visible_specs_owned)
.unwrap_or_else(|| self.tool_dispatcher.prompt_instructions(tools_slice));
+ drop(visible_specs_owned);
// Adapt the agent's whole callable surface into the shared PromptTool
// shape that every prompt-building call-site uses. Temporary vec
// borrows from the two tool `Arc`s and lives for the duration of the
diff --git a/src/openhuman/agent/harness/session/turn/tools.rs b/src/openhuman/agent/harness/session/turn/tools.rs
index ae16d7e79b..2a9e847cc3 100644
--- a/src/openhuman/agent/harness/session/turn/tools.rs
+++ b/src/openhuman/agent/harness/session/turn/tools.rs
@@ -591,8 +591,8 @@ impl Agent {
);
let synthed_names: std::collections::HashSet<String> =
synthed.iter().map(|t| t.name().to_string()).collect();
- let synthed_specs: Vec<crate::openhuman::tools::ToolSpec> =
- synthed.iter().map(|t| t.spec()).collect();
+ let synthed_specs: Vec<Arc<crate::openhuman::tools::ToolSpec>> =
+ synthed.iter().map(|t| Arc::new(t.spec())).collect();
// Skip mutation when neither the previous nor the next synthesis
// produced any names — saves work on agents without dynamic
diff --git a/src/openhuman/agent/harness/subagent_runner/ops/runner.rs b/src/openhuman/agent/harness/subagent_runner/ops/runner.rs
index ca40044b4f..2c112fa97f 100644
--- a/src/openhuman/agent/harness/subagent_runner/ops/runner.rs
+++ b/src/openhuman/agent/harness/subagent_runner/ops/runner.rs
@@ -1247,7 +1247,7 @@ async fn run_typed_mode(
filtered_specs.extend(
allowed_indices
.iter()
- .map(|&i| parent.all_tool_specs[i].clone()),
+ .map(|&i| parent.all_tool_specs[i].as_ref().clone()),
);
let mut allowed_names: HashSet<String> = allowed_indices
.iter()
diff --git a/src/openhuman/agent/orchestration/tools/agent_prepare_context_part_01.rs b/src/openhuman/agent/orchestration/tools/agent_prepare_context_part_01.rs
index d6df199ef9..9ec46931c6 100644
--- a/src/openhuman/agent/orchestration/tools/agent_prepare_context_part_01.rs
+++ b/src/openhuman/agent/orchestration/tools/agent_prepare_context_part_01.rs
@@ -584,7 +584,8 @@ impl AgentPrepareContextTool {
return String::new();
};
let visible = &parent.visible_tool_names;
- let specs: &[crate::openhuman::tools::ToolSpec] = if parent.visible_tool_specs.is_empty() {
+ let specs: &[Arc<crate::openhuman::tools::ToolSpec>] = if parent.visible_tool_specs.is_empty()
+ {
&parent.all_tool_specs
} else {
&parent.visible_tool_specs
diff --git a/src/openhuman/mcp/server/tools/dispatch.rs b/src/openhuman/mcp/server/tools/dispatch.rs
index 4c9a139c20..222b5b2cdb 100644
--- a/src/openhuman/mcp/server/tools/dispatch.rs
+++ b/src/openhuman/mcp/server/tools/dispatch.rs
@@ -237,7 +237,11 @@ async fn list_core_tools() -> Result<Value, ToolCallError> {
async fn core_tool_instructions() -> Result<Value, ToolCallError> {
let agent = build_orchestrator_agent().await?;
- let schemas: Vec<_> = agent.tool_specs().iter().map(spec_to_schema).collect();
+ let schemas: Vec<_> = agent
+ .tool_specs()
+ .iter()
+ .map(|spec| spec_to_schema(spec))
+ .collect();
Ok(tool_text_success(
tinyagents_harness::tool::prompt_tool_instructions(&schemas),
))