AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(backend/copilot): prevent title update from overwriting session messages (#12302)
Zamil Majdy21c705af6eba
diff --git a/autogpt_platform/backend/backend/copilot/model.py b/autogpt_platform/backend/backend/copilot/model.pyindex c6ee34f62a..ece62b6b9e 100644--- a/autogpt_platform/backend/backend/copilot/model.py+++ b/autogpt_platform/backend/backend/copilot/model.py@@ -705,19 +705,10 @@ async def update_session_title(session_id: str, title: str) -> bool:logger.warning(f"Session {session_id} not found for title update")return False- # Update title in cache if it exists (instead of invalidating).- # This prevents race conditions where cache invalidation causes- # the frontend to see stale DB data while streaming is still in progress.- try:- cached = await _get_session_from_cache(session_id)- if cached:- cached.title = title- await cache_chat_session(cached)- except Exception as e:- # Not critical - title will be correct on next full cache refresh- logger.warning(- f"Failed to update title in cache for session {session_id}: {e}"- )+ # Invalidate the cache so the next access reloads from DB with the+ # updated title. This avoids a read-modify-write on the full session+ # blob, which could overwrite concurrent message updates.+ await invalidate_session_cache(session_id)return Trueexcept Exception as e: