From e9e45acd6d0f1be16047018c6fb9793c6efb66ac Mon Sep 17 00:00:00 2001 From: Chummy Date: Tue, 17 Feb 2026 18:50:31 +0800 Subject: [PATCH] providers: map native tool support from capabilities --- src/providers/traits.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/providers/traits.rs b/src/providers/traits.rs index fbe5170..f69ddd0 100644 --- a/src/providers/traits.rs +++ b/src/providers/traits.rs @@ -278,7 +278,7 @@ pub trait Provider: Send + Sync { /// Whether provider supports native tool calls over API. fn supports_native_tools(&self) -> bool { - false + self.capabilities().native_tool_calling } /// Warm up the HTTP connection pool (TLS handshake, DNS, HTTP/2 setup). @@ -358,6 +358,27 @@ pub trait Provider: Send + Sync { mod tests { use super::*; + struct CapabilityMockProvider; + + #[async_trait] + impl Provider for CapabilityMockProvider { + fn capabilities(&self) -> ProviderCapabilities { + ProviderCapabilities { + native_tool_calling: true, + } + } + + async fn chat_with_system( + &self, + _system_prompt: Option<&str>, + _message: &str, + _model: &str, + _temperature: f64, + ) -> anyhow::Result { + Ok("ok".into()) + } + } + #[test] fn chat_message_constructors() { let sys = ChatMessage::system("Be helpful"); @@ -442,4 +463,10 @@ mod tests { assert_eq!(caps1, caps2); assert_ne!(caps1, caps3); } + + #[test] + fn supports_native_tools_reflects_capabilities_default_mapping() { + let provider = CapabilityMockProvider; + assert!(provider.supports_native_tools()); + } }