From 2a4bb22d9929e4d5b16013ed8f34ba7c0bf438b7 Mon Sep 17 00:00:00 2001 From: abhi1992002 Date: Tue, 17 Feb 2026 12:10:48 +0530 Subject: [PATCH] fix(api): ensure field updates are preserved when updating library agent - Modified the `update_library_agent` function to apply any provided field updates before fetching the current agent, preventing loss of data during the update process. - This change enhances the integrity of the library agent update functionality by ensuring all relevant fields are retained. --- autogpt_platform/backend/backend/api/features/library/db.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/autogpt_platform/backend/backend/api/features/library/db.py b/autogpt_platform/backend/backend/api/features/library/db.py index 1c157589ec..33761eec09 100644 --- a/autogpt_platform/backend/backend/api/features/library/db.py +++ b/autogpt_platform/backend/backend/api/features/library/db.py @@ -670,6 +670,12 @@ async def update_library_agent( # If graph_version is provided, update to that specific version if graph_version is not None: + # Apply any other field updates first so they aren't lost + if update_fields: + await prisma.models.LibraryAgent.prisma().update_many( + where={"id": library_agent_id, "userId": user_id}, + data=update_fields, + ) # Get the current agent to find its graph_id agent = await get_library_agent(id=library_agent_id, user_id=user_id) # Update to the specified version using existing function