# ============================================================ # app/models/agent_delegate.py — AIDA Delegate Model # ============================================================ # Stores the "My Agent" mandate a user gives AIDA for a DM thread. # One record per (conversation_id, user_id) pair. # ============================================================ from datetime import datetime class AgentDelegate: COLLECTION = "aida_delegates" @staticmethod def create_document( conversation_id: str, user_id: str, instruction: str, ) -> dict: now = datetime.utcnow() return { "conversation_id": conversation_id, "user_id": user_id, "instruction": instruction, # the private mandate from the user "active": True, "turns_without_progress": 0, # Snapshot of last numeric offer/price seen in agent output. # Used by the progress-tracking logic to detect deadlock. "last_offer_snapshot": None, "created_at": now, "updated_at": now, }