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.
This commit is contained in:
abhi1992002
2026-02-17 12:10:48 +05:30
parent ee14e54e80
commit 2a4bb22d99

View File

@@ -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