{"record":{"id":"4cd185c4e99e1dfb","repo":"multica-ai/multica","slug":"chat-session-already-has-a-user-message","errorCode":null,"errorMessage":"chat session already has a user message","messagePattern":"chat session already has a user message","errorType":"validation","errorClass":"ErrChatSessionAlreadyStarted","httpStatus":null,"severity":"error","filePath":"server/internal/service/task.go","lineNumber":1884,"sourceCode":"\t\t\"issue_id\", util.UUIDToString(task.IssueID),\n\t\t\"agent_id\", util.UUIDToString(task.AgentID),\n\t)\n\ts.broadcastTaskEvent(ctx, protocol.EventTaskQueued, task)\n\ts.NotifyTaskEnqueued(ctx, task)\n\treturn nil\n}\n\n// DirectChatSendResult carries the rows a transactional direct-chat send\n// persisted, so the handler can broadcast the user message and shape its\n// response without re-reading them.\ntype DirectChatSendResult struct {\n\tTask               db.AgentTaskQueue\n\tMessage            db.ChatMessage\n\tBoundAttachmentIDs []pgtype.UUID\n\tQueued             bool\n}\n\nvar ErrChatSessionAlreadyStarted = errors.New(\"chat session already has a user message\")\n\n// SendDirectChatMessage atomically persists one web/mobile direct-chat turn:\n// the owning task (which claims its own input batch via chat_input_task_id), the\n// user message bound to that task, any attachment bindings, and the session\n// touch all commit together (MUL-4351). The daemon is only notified after the\n// commit, so it can never observe a message without a task or a task without its\n// input owner — and a later claim reads exactly this task's user messages\n// instead of scanning trailing history.\n//\n// The caller must have already gated the session and preflighted the agent\n// (archived / no-runtime), passing the loaded agent in. Those checks are repeated\n// under the transaction locks below because either row may change before enqueue.\nfunc (s *TaskService) SendDirectChatMessage(\n\tctx context.Context,\n\tsession db.ChatSession,\n\tagent db.Agent,\n\tinitiatorUserID pgtype.UUID,\n\tcontent string,","sourceCodeStart":1866,"sourceCodeEnd":1902,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/service/task.go#L1866-L1902","documentation":"Error \"chat session already has a user message\" thrown in multica-ai/multica.","triggerScenarios":"Thrown at server/internal/service/task.go:1884 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The chat session already has a user message; continue the existing session or create a new one."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}