Skip to content

Commit

Permalink
fix: async flush the memory when agent update
Browse files Browse the repository at this point in the history
  • Loading branch information
hyacinthus committed Feb 25, 2025
1 parent aaa04d9 commit 62f2215
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/admin/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import json
import logging

Expand Down Expand Up @@ -66,8 +67,9 @@ async def _process_agent(
if agent_data and agent_data.cdp_wallet_data:
has_wallet = True
wallet_data = json.loads(agent_data.cdp_wallet_data)
# Clean agent memory
await clean_agent_memory(latest_agent.id, clean_agent_memory=True)
# Run clean_agent_memory in background
import asyncio
asyncio.create_task(clean_agent_memory(latest_agent.id, clean_agent_memory=True))

if not has_wallet:
# create the wallet
Expand Down
1 change: 1 addition & 0 deletions app/core/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ async def clean_agent_memory(

await db.commit()

logger.info(f"Agent [{agent_id}] data cleaned up successfully.")
return "Agent data cleaned up successfully."
except SQLAlchemyError as e:
# Handle other SQLAlchemy-related errors
Expand Down

0 comments on commit 62f2215

Please sign in to comment.