Skip to content

Commit a683f05

Browse files
update save database logic
1 parent fa0069a commit a683f05

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/backend/v4/magentic_agents/foundry_agent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,12 @@ async def invoke(self, prompt: str):
299299

300300
messages = [ChatMessage(role=Role.USER, text=prompt)]
301301

302+
agent_saved = False
302303
async for update in self._agent.run_stream(messages):
303-
if self._agent.chat_client.agent_id:
304+
# Save agent ID only once on first update (agent ID won't change during streaming)
305+
if not agent_saved and self._agent.chat_client.agent_id:
304306
await self.save_database_team_agent()
307+
agent_saved = True
305308
yield update
306309

307310
# -------------------------

0 commit comments

Comments
 (0)