MCPcopy
hub / github.com/dataelement/Clawith / _create_task_record

Method _create_task_record

backend/app/api/websocket.py:1048–1070  ·  view source on GitHub ↗

Creates a background execution task from task matching.

(self, task_title: str, assistant_response: str)

Source from the content-addressed store, hash-verified

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."""

Callers 1

message_loopMethod · 0.95

Calls 5

TaskClass · 0.90
execute_taskFunction · 0.90
addMethod · 0.45
commitMethod · 0.45
refreshMethod · 0.45

Tested by

no test coverage detected