diff --git a/src/config/request_context.rs b/src/config/request_context.rs index 864f2d7..fbdab8d 100644 --- a/src/config/request_context.rs +++ b/src/config/request_context.rs @@ -2041,11 +2041,15 @@ impl RequestContext { } else { self.update_app_config(|app| app.auto_continue = value); } - if value + let should_register = self.agent.is_none() && self.app.config.function_calling_support - && !self.tool_scope.functions.contains("todo__init") - { + && self.auto_continue_config().enabled; + let already_registered = self.tool_scope.functions.contains("todo__init"); + + if should_register && !already_registered { self.tool_scope.functions.append_todo_functions(); + } else if !should_register && already_registered { + self.tool_scope.functions.remove_todo_functions(); } } "max_auto_continues" => { diff --git a/src/function/mod.rs b/src/function/mod.rs index 30b1c40..79b77b5 100644 --- a/src/function/mod.rs +++ b/src/function/mod.rs @@ -357,6 +357,11 @@ impl Functions { self.declarations.extend(todo::todo_function_declarations()); } + pub fn remove_todo_functions(&mut self) { + self.declarations + .retain(|f| !f.name.starts_with(TODO_FUNCTION_PREFIX)); + } + pub fn append_memory_functions(&mut self) { self.declarations .extend(memory::memory_function_declarations());