feat: Create the built-in memory management tools

This commit is contained in:
2026-06-10 18:35:59 -06:00
parent 4ece3d3df1
commit 19d2340489
4 changed files with 423 additions and 2 deletions
+14
View File
@@ -1,3 +1,4 @@
pub(crate) mod memory;
pub(crate) mod skill;
pub(crate) mod supervisor;
pub(crate) mod todo;
@@ -22,6 +23,7 @@ use indoc::formatdoc;
use rust_embed::Embed;
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use memory::MEMORY_FUNCTION_PREFIX;
use skill::SKILL_FUNCTION_PREFIX;
use std::collections::VecDeque;
use std::ffi::OsStr;
@@ -355,6 +357,11 @@ impl Functions {
self.declarations.extend(todo::todo_function_declarations());
}
pub fn append_memory_functions(&mut self) {
self.declarations
.extend(memory::memory_function_declarations());
}
pub fn append_skill_functions(&mut self) {
self.declarations
.extend(skill::skill_function_declarations());
@@ -1046,6 +1053,13 @@ impl ToolCall {
json!({"tool_call_error": error_msg})
})
}
_ if cmd_name.starts_with(MEMORY_FUNCTION_PREFIX) => {
memory::handle_memory_tool(ctx, &cmd_name, &json_data).unwrap_or_else(|e| {
let error_msg = format!("Memory tool failed: {e}");
eprintln!("{}", warning_text(&format!("⚠️ {error_msg} ⚠️")));
json!({"tool_call_error": error_msg})
})
}
_ if cmd_name.starts_with(SKILL_FUNCTION_PREFIX) => {
skill::handle_skill_tool(ctx, &cmd_name, &json_data)
.await