diff --git a/README.md b/README.md index 932cecf..6e8b25b 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,11 @@ Agents learn capabilities through skills — Nostr events that any agent can di Didactyl will support local inference, which is very privacy preserving. Remote inference does however have it's advantages, and in those cases Didactyl supports using Bitcoin Lightning and eCash inference providers. -## Current Status — v0.0.39 +## Current Status — v0.0.40 **Active build — this project is barely working. Experiment at your own risk.** -> Last release update: v0.0.39 — Rebuild didactyl with ws frame drain and larger relay buffers +> Last release update: v0.0.40 — Reduce query churn and add relay disconnect-cause visibility - Connects to configured relays with auto-reconnect and relay state transition logging - Publishes configured startup events per relay as each relay becomes connected diff --git a/src/agent.c b/src/agent.c index f90dc3b..ed1b962 100644 --- a/src/agent.c +++ b/src/agent.c @@ -35,7 +35,7 @@ static pthread_mutex_t g_context_part_names_mutex = PTHREAD_MUTEX_INITIALIZER; #define AGENT_DEBOUNCE_CACHE_SIZE 256 #define AGENT_HISTORY_TURNS 12 #define AGENT_HISTORY_QUERY_LIMIT 200 -#define AGENT_ADOPTED_SKILLS_CACHE_TTL_SECONDS 30 +#define AGENT_ADOPTED_SKILLS_CACHE_TTL_SECONDS 300 #define AGENT_ADOPTED_SKILLS_MAX 24 #define AGENT_ADOPTED_SKILL_CONTENT_MAX_CHARS 1800 #define AGENT_ADOPTED_SKILLS_TOTAL_MAX_CHARS 7200 @@ -1415,7 +1415,7 @@ static int append_recent_admin_dm_history(cJSON* messages, const char* current_m cJSON_AddItemToObject(filter, "authors", authors); cJSON_AddNumberToObject(filter, "limit", AGENT_HISTORY_QUERY_LIMIT); - char* events_json = nostr_handler_query_json(filter, 8000); + char* events_json = nostr_handler_query_json(filter, 1500); cJSON_Delete(filter); if (!events_json) { return 0; @@ -1648,7 +1648,7 @@ static int refresh_adopted_skills_cache_if_needed(void) { cJSON_AddItemToObject(adopt_filter, "authors", authors); cJSON_AddNumberToObject(adopt_filter, "limit", 1); - char* adoption_json = nostr_handler_query_json(adopt_filter, 8000); + char* adoption_json = nostr_handler_query_json(adopt_filter, 2000); cJSON_Delete(adopt_filter); cJSON* adoption_events = adoption_json ? cJSON_Parse(adoption_json) : NULL; @@ -1700,7 +1700,7 @@ static int refresh_adopted_skills_cache_if_needed(void) { cJSON_AddItemToObject(skill_filter, "#d", d_values); cJSON_AddNumberToObject(skill_filter, "limit", 1); - char* skill_json = nostr_handler_query_json(skill_filter, 8000); + char* skill_json = nostr_handler_query_json(skill_filter, 2000); cJSON_Delete(skill_filter); if (!skill_json) { continue; diff --git a/src/main.h b/src/main.h index 65c7d8c..411cc86 100644 --- a/src/main.h +++ b/src/main.h @@ -12,8 +12,8 @@ // Using DIDACTYL_ prefix to avoid conflicts with nostr_core_lib VERSION macros #define DIDACTYL_VERSION_MAJOR 0 #define DIDACTYL_VERSION_MINOR 0 -#define DIDACTYL_VERSION_PATCH 39 -#define DIDACTYL_VERSION "v0.0.39" +#define DIDACTYL_VERSION_PATCH 40 +#define DIDACTYL_VERSION "v0.0.40" // Agent metadata #define DIDACTYL_NAME "Didactyl" diff --git a/src/nostr_handler.c b/src/nostr_handler.c index e8f7cae..3a5232f 100644 --- a/src/nostr_handler.c +++ b/src/nostr_handler.c @@ -218,10 +218,19 @@ static void log_relay_state_changes(void) { nostr_pool_relay_status_t now = nostr_relay_pool_get_relay_status(g_pool, relay); nostr_pool_relay_status_t prev = g_last_relay_statuses[i]; if (now != prev) { - DEBUG_INFO("[didactyl] relay state changed: %s %s -> %s", - relay, - relay_status_str(prev), - relay_status_str(now)); + const char* conn_err = nostr_relay_pool_get_relay_last_connection_error(g_pool, relay); + if (conn_err && (now == NOSTR_POOL_RELAY_DISCONNECTED || now == NOSTR_POOL_RELAY_ERROR)) { + DEBUG_INFO("[didactyl] relay state changed: %s %s -> %s (cause: %s)", + relay, + relay_status_str(prev), + relay_status_str(now), + conn_err); + } else { + DEBUG_INFO("[didactyl] relay state changed: %s %s -> %s", + relay, + relay_status_str(prev), + relay_status_str(now)); + } g_last_relay_statuses[i] = now; if (now == NOSTR_POOL_RELAY_CONNECTED) { diff --git a/src/trigger_manager.c b/src/trigger_manager.c index 07e2044..1d04197 100644 --- a/src/trigger_manager.c +++ b/src/trigger_manager.c @@ -268,7 +268,7 @@ int trigger_manager_load_from_skills(trigger_manager_t* mgr) { cJSON_AddItemToObject(adopt_filter, "authors", authors); cJSON_AddNumberToObject(adopt_filter, "limit", 1); - char* adoption_json = nostr_handler_query_json(adopt_filter, 8000); + char* adoption_json = nostr_handler_query_json(adopt_filter, 2000); cJSON_Delete(adopt_filter); if (!adoption_json) { return 0; @@ -328,7 +328,7 @@ int trigger_manager_load_from_skills(trigger_manager_t* mgr) { cJSON_AddItemToObject(skill_filter, "#d", d_values); cJSON_AddNumberToObject(skill_filter, "limit", 1); - char* skill_json = nostr_handler_query_json(skill_filter, 8000); + char* skill_json = nostr_handler_query_json(skill_filter, 2000); cJSON_Delete(skill_filter); if (!skill_json) { continue; @@ -513,7 +513,7 @@ int trigger_manager_poll(trigger_manager_t* mgr) { } time_t now = time(NULL); - if (mgr->last_poll_at > 0 && (now - mgr->last_poll_at) < 2) { + if (mgr->last_poll_at > 0 && (now - mgr->last_poll_at) < 10) { return 0; } mgr->last_poll_at = now; @@ -538,7 +538,7 @@ int trigger_manager_poll(trigger_manager_t* mgr) { cJSON_AddNumberToObject(filter, "since", (double)since); cJSON_AddNumberToObject(filter, "limit", 8); - char* events_json = nostr_handler_query_json(filter, 4000); + char* events_json = nostr_handler_query_json(filter, 1200); cJSON_Delete(filter); if (!events_json) { continue;