Creates a background execution task from task matching.
(self, task_title: str, assistant_response: str)
| 1046 | logger.warning(f"[WS] Failed to log activity: {e}") |
| 1047 | |
| 1048 | async def _create_task_record(self, task_title: str, assistant_response: str) -> str: |
| 1049 | """Creates a background execution task from task matching.""" |
| 1050 | if not task_title: |
| 1051 | return assistant_response |
| 1052 | try: |
| 1053 | async with async_session() as db: |
| 1054 | task = Task( |
| 1055 | agent_id=self.agent_id, |
| 1056 | title=task_title, |
| 1057 | created_by=self.user.id, |
| 1058 | status="pending", |
| 1059 | priority="medium", |
| 1060 | ) |
| 1061 | db.add(task) |
| 1062 | await db.commit() |
| 1063 | await db.refresh(task) |
| 1064 | logger.info(f"[WS] Task created: {task.id}") |
| 1065 | task_id = task.id |
| 1066 | asyncio.create_task(execute_task(task_id, self.agent_id)) |
| 1067 | assistant_response += f"\n\n📋 Task synced to task board: [{task_title}]" |
| 1068 | except Exception as te: |
| 1069 | logger.error(f"[WS] Task creation failed: {te}") |
| 1070 | return assistant_response |
| 1071 | |
| 1072 | async def _save_assistant_reply(self, assistant_response: str, thinking_content: list[str]): |
| 1073 | """Saves assistant reply to DB.""" |
no test coverage detected