diff --git a/src/client/model.rs b/src/client/model.rs index 6d2dfbd..c55c045 100644 --- a/src/client/model.rs +++ b/src/client/model.rs @@ -177,6 +177,10 @@ impl Model { self.data.max_output_tokens } + pub fn supports_function_calling(&self) -> bool { + self.data.supports_function_calling + } + pub fn no_stream(&self) -> bool { self.data.no_stream } diff --git a/src/config/input.rs b/src/config/input.rs index 8578b9c..ab4e029 100644 --- a/src/config/input.rs +++ b/src/config/input.rs @@ -239,12 +239,17 @@ impl Input { patch_messages(&mut messages, model); model.guard_max_input_tokens(&messages)?; let (temperature, top_p) = (self.role().temperature(), self.role().top_p()); - let functions = self.config.read().select_functions(self.role()); - if let Some(vec) = &functions { - for def in vec { - debug!("Function definition: {:?}", def.name); + let functions = if model.supports_function_calling() { + let fns = self.config.read().select_functions(self.role()); + if let Some(vec) = &fns { + for def in vec { + debug!("Function definition: {:?}", def.name); + } } - } + fns + } else { + None + }; Ok(ChatCompletionsData { messages, temperature, diff --git a/src/config/mod.rs b/src/config/mod.rs index 2121f5f..bd788c5 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1842,6 +1842,12 @@ impl Config { bail!("Already in an agent, please run '.exit agent' first to exit the current agent."); } let agent = Agent::init(config, agent_name, abort_signal.clone()).await?; + if !agent.model().supports_function_calling() { + eprintln!( + "Warning: The model '{}' does not support function calling. Agent tools (including todo, spawning, and user interaction) will not be available.", + agent.model().id() + ); + } let session = session_name.map(|v| v.to_string()).or_else(|| { if config.read().macro_flag { None