Skip to content

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

docs(agent): document shared tool spec schemas

Steven Enamakel0866c61c55f8
diff --git a/src/openhuman/agent/harness/session/types.rs b/src/openhuman/agent/harness/session/types.rs
index 7478caf078..e9128ce154 100644
--- a/src/openhuman/agent/harness/session/types.rs
+++ b/src/openhuman/agent/harness/session/types.rs
@@ -115,6 +115,18 @@ pub struct Agent {
pub(super) synthesized_tools: Arc<Vec<Box<dyn Tool>>>,
/// Full tool specs: [`Self::tools`]' specs first, then the synthesised
/// half, which [`Agent::refresh_delegation_tools`] swaps in place.
+ ///
+ /// The leaves are `Arc<ToolSpec>` and are **shared** with
+ /// [`Self::durable_tool_specs`] and [`Self::visible_tool_specs`]: all three
+ /// views point at the same schema objects, so a JSON-Schema `parameters`
+ /// value is resident once per agent rather than three times
+ /// (openhuman#6218 — it was ~1.1 MiB of the ~2.5 MiB a live agent cost).
+ /// `refresh_delegation_tools` preserves that: `Arc::make_mut` clones the
+ /// vector of pointers, never the schemas behind them. Anything that
+ /// rebuilds an entry instead of cloning its `Arc` silently reintroduces the
+ /// copy, which is why
+ /// `builder_tests::part_01_tests::the_three_spec_views_share_their_leaf_schemas`
+ /// asserts pointer identity rather than equal contents.
pub(super) tool_specs: Arc<Vec<Arc<ToolSpec>>>,
/// The specs of [`Self::tools`] alone, index for index. Sub-agents receive
/// these via [`ParentExecutionContext::all_tool_specs`] beside