From b5601722c79de4e5170dfd62368238440293f316 Mon Sep 17 00:00:00 2001 From: Bentlybro Date: Tue, 7 Apr 2026 18:35:41 +0100 Subject: [PATCH] feat(backend/llm-registry): wire refresh_runtime_caches to Redis invalidation and pub/sub After any admin DB mutation, clear the shared Redis cache, refresh this process's in-memory state, then publish a notification so all other workers reload from Redis without hitting the database. --- .../backend/backend/server/v2/llm/db_write.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/autogpt_platform/backend/backend/server/v2/llm/db_write.py b/autogpt_platform/backend/backend/server/v2/llm/db_write.py index 8d9a246205..87b0f9ab4a 100644 --- a/autogpt_platform/backend/backend/server/v2/llm/db_write.py +++ b/autogpt_platform/backend/backend/server/v2/llm/db_write.py @@ -575,5 +575,14 @@ async def revert_migration( async def refresh_runtime_caches() -> None: - """Refresh the LLM registry and clear all related caches.""" + """Invalidate the shared Redis cache, refresh this process, notify other workers.""" + from backend.data.llm_registry.notifications import ( + publish_registry_refresh_notification, + ) + + # Invalidate Redis so the next fetch hits the DB. + llm_registry.clear_registry_cache() + # Refresh this process (also repopulates Redis via @cached(shared_cache=True)). await llm_registry.refresh_llm_registry() + # Tell other workers to reload their in-process cache from the fresh Redis data. + await publish_registry_refresh_notification()