{"record":{"id":"a5ec95fe22daa635","repo":"Hmbown/CodeWhale","slug":"task-was-created-but-work-lifecycle-reconciliation-failed","errorCode":null,"errorMessage":"task was created but Work lifecycle reconciliation failed","messagePattern":"task was created but Work lifecycle reconciliation failed","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/tasks.rs","lineNumber":521,"sourceCode":"        }\n        let task = match manager.add_task_with_id(req, task_id.clone()).await {\n            Ok(task) => task,\n            Err(err) => {\n                if let Some(work) = context.runtime.work.as_ref() {\n                    let _ = work.reconcile_operation(\n                        &context.state_namespace,\n                        OperationOwnerSnapshot::new(\n                            format!(\"task:{task_id}\"),\n                            OwnerState::Failed,\n                            1,\n                            Utc::now().timestamp_millis(),\n                        ),\n                    );\n                }\n                return Err(ToolError::execution_failed(err.to_string()));\n            }\n        };\n        let lifecycle_warning = reconcile_task_record(context, &task).err().map(|err| {\n            tracing::warn!(task_id = %task.id, error = %err, \"task was created but Work lifecycle reconciliation failed\");\n            err.to_string()\n        });\n        task_result_with_lifecycle_warning(\"task_create\", &task, lifecycle_warning.as_deref())\n    }\n\n    async fn execute_list(\n        &self,\n        input: &Value,\n        context: &ToolContext,\n    ) -> Result<ToolResult, ToolError> {\n        let manager = context\n            .runtime\n            .task_manager\n            .as_ref()\n            .ok_or_else(|| ToolError::not_available(\"TaskManager is not attached\"))?;\n        let limit = optional_u64(input, \"limit\", 20)?.clamp(1, 100) as usize;\n        let tasks = manager","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/tools/tasks.rs#L503-L539","documentation":"This is a ToolError::execution_failed raised in tasks.rs when a task record was successfully created but the follow-up reconciliation with the Work lifecycle (reconcile_task_record) failed. The library treats the lifecycle sync as a post-create step: the task exists, so the error carries a warning flavor but is surfaced as an execution failure string so the agent/user knows the task is not fully registered with the Work lifecycle.","triggerScenarios":"Calling the task_create tool's execute path where the task is created fine but reconcile_task_record(context, &task) returns Err — e.g. the Work lifecycle store is unavailable, the record cannot be linked, or lifecycle state validation rejects the new task.","commonSituations":"Work lifecycle state missing or not initialized in the session context; a task created outside the tool (manual edits) leaving inconsistent lifecycle state; schema drift between task records and the lifecycle store.","solutions":["Note that the task WAS created — do not recreate it; instead retry the reconciliation (re-running the tool may duplicate the task).","Check that the Work lifecycle state exists in the session context and is initialized before creating tasks.","Inspect the underlying error text (it is included in the ToolError) for the specific lifecycle failure and fix that state.","If lifecycle records drifted, repair or reset the lifecycle record for the task id rather than deleting the task."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure Work lifecycle context is initialized before creating tasks\nif context.lifecycle_store().is_err() {\n    return Err(ToolError::execution_failed(\"Work lifecycle not initialized\"));\n}","typeGuard":null,"tryCatchPattern":"match reconcile_task_record(context, &task) {\n    Err(err) => tracing::warn!(task_id = %task.id, \"created but reconciliation failed: {err}\"),\n    Ok(_) => {}\n}","preventionTips":["Initialize the Work lifecycle store before running task tools.","Do not create or edit task records outside the tool surface.","Keep task record and lifecycle schemas in sync across versions.","On failure, retry reconciliation rather than recreating the task."],"tags":["task-management","lifecycle","reconciliation","tool-error"],"backgroundTag":"invalid-state-transition","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}