From 7143b50d98c7ee52e1acf79b5ac515bd2e700c2c Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Wed, 10 Jun 2026 21:07:56 -0600 Subject: [PATCH] fix: append memory functions to non-graph based agents on init --- src/config/agent.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/config/agent.rs b/src/config/agent.rs index b3277e4..5950b44 100644 --- a/src/config/agent.rs +++ b/src/config/agent.rs @@ -2,6 +2,7 @@ use super::*; use crate::{ client::Model, + config::memory, function::{Functions, run_llm_function}, }; @@ -19,7 +20,7 @@ use fancy_regex::Captures; use inquire::{Text, validator::Validation}; use rust_embed::Embed; use serde::{Deserialize, Serialize}; -use std::{ffi::OsStr, path::Path}; +use std::{env, ffi::OsStr, path::Path}; const DEFAULT_AGENT_NAME: &str = "rag"; @@ -214,6 +215,20 @@ impl Agent { functions.append_skill_functions(); } + if app.function_calling_support + && !matches!(agent_config.memory, Some(false)) + && !matches!(app.memory, Some(false)) + { + let memory_exists = paths::global_memory_index_path().exists() + || env::current_dir() + .ok() + .and_then(|cwd| memory::discover_workspace_memory(&cwd)) + .is_some(); + if memory_exists { + functions.append_memory_functions(); + } + } + agent_config.replace_tools_placeholder(&functions); Ok(Self {