{"record":{"id":"49d1beafe6cf05c5","repo":"nanocoai/nanoclaw","slug":"failed-to-append-task-run-log","errorCode":null,"errorMessage":"Failed to append task run log","messagePattern":"Failed to append task run log","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/delivery.ts","lineNumber":318,"sourceCode":"  const content = JSON.parse(msg.content);\n\n  // System actions — handle internally (cli_request, etc.)\n  if (msg.kind === 'system') {\n    await handleSystemAction(content, session);\n    return;\n  }\n\n  // Task-run log: the runner mirrors a run's final text here (one-door\n  // delivery — final text never reaches a channel; the send_message tool is\n  // the only delivery path from a task session). Append to the series log,\n  // never deliver. The caller marks it delivered so it isn't retried.\n  if (msg.kind === 'task_log') {\n    if (session.messaging_group_id === null && isTaskThread(session.thread_id) && session.thread_id) {\n      const series = session.thread_id.slice(`${TASKS_SYSTEM_THREAD_ID}:`.length);\n      try {\n        await appendRunLog(session.agent_group_id, series, typeof content.text === 'string' ? content.text : '');\n      } catch (err) {\n        log.warn('Failed to append task run log', { id: msg.id, sessionId: session.id, err });\n      }\n    } else {\n      log.warn('task_log row outside a task session — ignoring', { id: msg.id, sessionId: session.id });\n    }\n    return;\n  }\n\n  // Agent-to-agent — route to target session via the agent-to-agent module.\n  // Guarded by the channel_type check. If the module isn't installed the\n  // `agent_destinations` table won't exist and `routeAgentMessage`'s permission\n  // check will throw, which falls into the normal retry → mark-failed path.\n  if (msg.channelType === 'agent') {\n    if (!(await hasTable(getDb(), 'agent_destinations'))) {\n      throw new Error(`agent-to-agent module not installed — cannot route message ${msg.id}`);\n    }\n    const { routeAgentMessage } = await import('./modules/agent-to-agent/agent-route.js');\n    await routeAgentMessage(\n      {","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/delivery.ts#L300-L336","documentation":"A task_log message targeted a task thread but appendRunLog failed to write to the group's run log file. The log line is lost; the task itself continues.","triggerScenarios":"appendRunLog throws — run-log file or its directory is unwritable/missing, disk full, or path issues in groups/<folder>/.","commonSituations":"Group folder perms changed, disk full, or the group directory was moved/deleted out from under the host.","solutions":["Check the group folder path exists and is writable by the host user","Free disk space if full","Verify task run-log destination via `ncl tasks get`","Task output is also in messages_out — regenerate the log if needed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import fs from 'node:fs';\nfs.accessSync(groupDir, fs.constants.W_OK); // verify before task runs","typeGuard":null,"tryCatchPattern":"try { await appendRunLog(...); } catch { /* keep task output in messages_out as source of truth */ }","preventionTips":["Keep group directories writable by the host user","Monitor disk space","Treat messages_out as canonical; run logs are derived"],"tags":["tasks","run-log","filesystem"],"backgroundTag":"log-write-failed","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}