Fix default agent creation to allow chat on first run

Previously agent slug was not considered on create even when passed
explicitly in agent creation step.

This made the default agent slug different until next run when it was
updated after creation. And didn't allow chat to work on first run

The fix to use the agent slug when explicitly passed allows users to
chat on first run.
This commit is contained in:
Debanjum
2025-03-28 19:04:10 +05:30
parent 03de2803f0
commit 72986c905a

View File

@@ -313,7 +313,7 @@ class Agent(DbBaseModel):
if self.creator is None:
self.managed_by_admin = True
if is_new:
if is_new and not self.slug:
random_sequence = "".join(choice("0123456789") for i in range(6))
slug = f"{self.name.lower().replace(' ', '-')}-{random_sequence}"
self.slug = slug