From e283957c8f4a325fbac57f8a4679c14a7df65272 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 22 Aug 2025 11:41:35 +0100 Subject: [PATCH] Fix source field retrieval in SharedAgent to handle DBRef correctly --- application/api/user/routes.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/application/api/user/routes.py b/application/api/user/routes.py index 9a2febbc..486690fb 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -1984,7 +1984,12 @@ class SharedAgent(Resource): else "" ), "description": shared_agent.get("description", ""), - "source": shared_agent.get("source", ""), + "source": ( + str(source_doc["_id"]) + if isinstance(shared_agent.get("source"), DBRef) + and (source_doc := db.dereference(shared_agent.get("source"))) + else "" + ), "chunks": shared_agent.get("chunks", "0"), "retriever": shared_agent.get("retriever", "classic"), "prompt_id": shared_agent.get("prompt_id", "default"),