From d13044d267e459832d481d081a5666af776bf41d Mon Sep 17 00:00:00 2001 From: Didactyl User Date: Tue, 28 Apr 2026 07:34:17 -0400 Subject: [PATCH] chore(agent): remove dead DM-history helper functions and orphaned constants --- src/agent.c | 81 ----------------------------------------------------- 1 file changed, 81 deletions(-) diff --git a/src/agent.c b/src/agent.c index 09cfce5..4e4c27d 100644 --- a/src/agent.c +++ b/src/agent.c @@ -35,8 +35,6 @@ static pthread_mutex_t g_context_part_names_mutex = PTHREAD_MUTEX_INITIALIZER; #define AGENT_DEBOUNCE_WINDOW_SECONDS 5 #define AGENT_DEBOUNCE_CACHE_SIZE 256 -#define AGENT_HISTORY_TURNS 12 -#define AGENT_HISTORY_QUERY_LIMIT 200 #define AGENT_ADOPTED_SKILLS_CACHE_TTL_SECONDS 300 #define AGENT_ADOPTED_SKILLS_MAX 24 #define AGENT_ADOPTED_SKILL_CONTENT_MAX_CHARS 1800 @@ -1062,73 +1060,6 @@ static __attribute__((unused)) char* build_sender_verification_text(didactyl_sen } -static __attribute__((unused)) int append_recent_admin_dm_history(cJSON* messages, const char* current_message) { - if (!messages || !g_cfg) { - return -1; - } - - char* history_json = nostr_handler_get_dm_history_json(g_cfg->admin.pubkey, AGENT_HISTORY_TURNS); - if (!history_json) { - return 0; - } - - cJSON* items = cJSON_Parse(history_json); - free(history_json); - if (!items || !cJSON_IsArray(items)) { - cJSON_Delete(items); - return 0; - } - - const char* last_appended_role = NULL; - const char* last_appended_content = NULL; - - int n = cJSON_GetArraySize(items); - for (int i = 0; i < n; i++) { - cJSON* item = cJSON_GetArrayItem(items, i); - cJSON* role = item ? cJSON_GetObjectItemCaseSensitive(item, "role") : NULL; - cJSON* content = item ? cJSON_GetObjectItemCaseSensitive(item, "content") : NULL; - cJSON* created_at = item ? cJSON_GetObjectItemCaseSensitive(item, "created_at") : NULL; - - if (!role || !content || !cJSON_IsString(role) || !cJSON_IsString(content) || - !role->valuestring || !content->valuestring) { - continue; - } - - const char* role_s = role->valuestring; - const char* content_s = content->valuestring; - int role_is_user = (strcmp(role_s, "user") == 0); - if (!role_is_user && strcmp(role_s, "assistant") != 0) { - continue; - } - - if (i == n - 1 && role_is_user && current_message && strcmp(content_s, current_message) == 0) { - continue; - } - - if (last_appended_role && last_appended_content && - strcmp(last_appended_role, role_s) == 0 && - strcmp(last_appended_content, content_s) == 0) { - continue; - } - - if (append_simple_message(messages, role_s, content_s) != 0) { - cJSON_Delete(items); - return -1; - } - - cJSON* appended = cJSON_GetArrayItem(messages, cJSON_GetArraySize(messages) - 1); - if (appended && cJSON_IsObject(appended) && created_at && cJSON_IsNumber(created_at)) { - cJSON_AddNumberToObject(appended, "_ts", created_at->valuedouble); - } - - last_appended_role = role_s; - last_appended_content = content_s; - } - - cJSON_Delete(items); - return 0; -} - static cJSON* find_tag_value_string_local(cJSON* tags, const char* key) { if (!tags || !key || !cJSON_IsArray(tags)) { return NULL; @@ -1797,18 +1728,6 @@ static __attribute__((unused)) int append_adopted_skills_context(cJSON* messages return rc; } -static __attribute__((unused)) cJSON* build_recent_admin_dm_history_messages(const char* current_message) { - cJSON* messages = cJSON_CreateArray(); - if (!messages) { - return NULL; - } - if (append_recent_admin_dm_history(messages, current_message) != 0) { - cJSON_Delete(messages); - return NULL; - } - return messages; -} - int agent_init(didactyl_config_t* config) { if (!config) { return -1;