Skip to content

Commit

Permalink
fix: agent update bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hyacinthus committed Mar 3, 2025
1 parent 997f1bd commit ae2e741
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions models/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,15 @@ async def create_or_update(self) -> ("Agent", bool):
detail="upstream_id cannot be changed after creation",
)
# Update existing agent
for field in self.model_fields:
if field != "id": # Skip the primary key
if getattr(self, field) is not None:
setattr(existing_agent, field, getattr(self, field))
for field, value in self.model_dump(exclude_unset=True).items():
if (
field != "id"
and field != "number"
and field != "created_at"
and field != "updated_at"
and field != "owner"
): # Skip the primary key
setattr(existing_agent, field, value)
async with get_session() as db:
db.add(existing_agent)
await db.commit()
Expand Down

0 comments on commit ae2e741

Please sign in to comment.