diff --git a/web/paperclip_client.py b/web/paperclip_client.py index 91785fd..204f182 100644 --- a/web/paperclip_client.py +++ b/web/paperclip_client.py @@ -268,13 +268,19 @@ async def _create_issue( issue_number = row["issue_counter"] identifier = f"{prefix}-{issue_number}" + # Assign to the company's CEO so Paperclip's wakeup gate + # (heartbeat staleness check) accepts the wakeup. Without this, + # the run is cancelled with "issue assignee changed before the + # queued run could start" and the agent never starts. + ceo_agent_id = CEO_AGENTS.get(company_id, CEO_AGENT_ID) + await conn.execute( - """INSERT INTO issues (id, company_id, project_id, title, description, status, priority, issue_number, identifier) - VALUES ($1, $2::uuid, $3::uuid, $4, $5, 'todo', 'medium', $6, $7)""", + """INSERT INTO issues (id, company_id, project_id, title, description, status, priority, issue_number, identifier, assignee_agent_id) + VALUES ($1, $2::uuid, $3::uuid, $4, $5, 'todo', 'medium', $6, $7, $8::uuid)""", issue_id, company_id, project_id, f"[ערר {case_number}] {title}"[:200], f"תיק ערר {case_number}\nנוצר אוטומטית מממשק העלאת מסמכים", - issue_number, identifier, + issue_number, identifier, ceo_agent_id, ) logger.info("Created Paperclip issue %s: [ערר %s] %s", identifier, case_number, title)