Fix source field retrieval in SharedAgent to handle DBRef correctly

This commit is contained in:
Alex
2025-08-22 11:41:35 +01:00
parent 7ae5a9c5a5
commit e283957c8f

View File

@@ -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"),