Skip to content

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

feat(inference): add supports_native_tool_calling method

Steven Enamakel289bf58509fc
diff --git a/crates/openhuman-core/src/inference/turn_models.rs b/crates/openhuman-core/src/inference/turn_models.rs
index ae45feb850..317fbf48ac 100644
--- a/crates/openhuman-core/src/inference/turn_models.rs
+++ b/crates/openhuman-core/src/inference/turn_models.rs
@@ -346,6 +346,40 @@ impl TurnModelSource {
(self.crate_native.as_ref()).map_or_else(DispatchCtx::ambient, CrateNativeSource::ctx)
}
+ /// Whether the selected primary accepts native tool calls, without building
+ /// models or publishing the per-turn egress disclosures that model
+ /// construction owns. Session assembly needs this before the actual turn
+ /// is built; using `build` here would create a second per-turn ledger.
+ pub(crate) fn supports_native_tool_calling(&self) -> bool {
+ if let Some(source) = &self.crate_native {
+ if let Some(custom) = source
+ .ctx()
+ .host_overrides()
+ .and_then(|local| local.model_for(&source.role))
+ {
+ return custom
+ .profile()
+ .cloned()
+ .unwrap_or_default()
+ .tool_calling;
+ }
+ }
+ if let Some(direct) = &self.direct_model {
+ return direct
+ .profile()
+ .cloned()
+ .unwrap_or_default()
+ .tool_calling;
+ }
+ if let Some(source) = &self.crate_native {
+ let provider_string = source.primary_override.as_deref().map(str::to_owned).unwrap_or_else(|| {
+ crate::inference::provider::provider_for_role(&source.role, &source.config)
+ });
+ return !tinyinference_local::profile::is_local_provider_string(&provider_string);
+ }
+ false
+ }
+
/// Use an already-constructed TinyAgents model as the complete turn model
/// source. Intended for deterministic tests and embedding callers that do
/// not need role/config-based route construction.
@@ -509,7 +543,7 @@ impl TurnModelSource {
.provider
.clone()
.unwrap_or_else(|| "injected".to_string());
- let native_tools = profile.tool_calling;
+ let native_tools = self.supports_native_tool_calling();
let supports_vision = profile.modalities.image_in;
let is_local =
crate::agent::tinyagents::turn_policy::provider_is_self_hosted(&provider_id, None);
@@ -578,7 +612,7 @@ impl TurnModelSource {
context_window,
cn.primary_override.as_deref(),
provider_id,
- !is_local,
+ self.supports_native_tool_calling(),
!is_local,
self_hosted,
thread_id,