Repository navigation
Description
Context
#544 proposes moving Maka toward a durable, recoverable, observable, and orchestratable agent platform.
One suggested roadmap item is Task model hardening:
tighten task status, claim/review/done flow, artifact linkage, failure reason, owner, and assignee semantics.
This issue focuses on the smallest durable task model that can support long-running agent work, recovery, observability, and future workflow orchestration without turning tasks
into a UI-only checklist or a subagent dispatch queue.
Problem
Long agent work often contains many implicit tasks, but without structured runtime state, Maka cannot reliably answer:
- what task is currently active?
- which tasks are done, blocked, failed, or still pending?
- what evidence proves a task is complete?
- what caused a task to become blocked?
- which run/tool/artifact produced the evidence?
- after interruption or restart, which task state is still trusted?
Free-text checklists help the model reason, but they are not enough as a durable platform contract.
Goals
Define a minimal durable task lifecycle model for Maka.
The model should:
- provide a typed task record;
- define allowed status transitions;
- require evidence for completed / blocked / failed states;
- link tasks to session/run/tool/artifact references;
- support conservative resume behavior after interruption;
- be observable through runtime events or trace projections;
- stay independent from subagent dispatch;
- stay independent from heavy project-management UI.
Non-goals
This issue does not aim to:
- build a full workflow engine;
- implement multi-agent assignment;
- implement cron / automation scheduling;
- replace existing AgentRun or RuntimeEvent models;
- create a large project-management UI;
- treat task status as stronger than filesystem, git, test, or tool evidence;
- make tasks a permission boundary.
Proposed Task Record
type TaskStatus =
| "pending"
| "in_progress"
| "blocked"
| "completed"
| "failed"
| "cancelled";
interface AgentTask {
id: string;
sessionId: string;
parentTaskId?: string;
title: string;
description?: string;
status: TaskStatus;
createdAt: string;
updatedAt: string;
owner?: "main_agent" | "user" | "system";
assignee?: string;
currentRunId?: string;
relatedRunIds?: string[];
relatedToolCallIds?: string[];
artifactRefs?: string[];
blockedReason?: string;
failureReason?: string;
completionEvidence?: string;
resumeTrust?: "trusted" | "needs_revalidation" | "stale" | "repaired" | "untrusted";
}This is intentionally small. Fields can be added later only when a concrete workflow needs them.
Status Semantics
Suggested status meanings:
pending: declared but not started.in_progress: actively being worked on.blocked: cannot continue without external input, missing dependency, permission, or failed prerequisite.completed: finished with evidence.failed: attempted and ended unsuccessfully with a reason.cancelled: intentionally stopped and should not be resumed automatically.
Transition Rules
Suggested allowed transitions:
pending -> in_progress
pending -> cancelled
in_progress -> blocked
in_progress -> completed
in_progress -> failed
in_progress -> cancelled
blocked -> in_progress
blocked -> cancelled
blocked -> failed
failed -> pending
failed -> cancelled
completed -> in_progress only if explicitly reopened
cancelled -> pending only if explicitly reopened
Invalid transitions should be rejected or recorded as repair events.
Evidence Rules
Some statuses should require evidence:
blockedrequiresblockedReason.failedrequiresfailureReason.completedrequirescompletionEvidence.
Evidence should prefer durable references when possible:
- tool call id;
- run id;
- file/artifact ref;
- test command result;
- user confirmation;
- verifier/scorer result;
- diff or patch ref.
A task marked completed should not override reality. If later filesystem/git/test evidence contradicts it, resume should mark it as needs_revalidation or reopen it.
Runtime Events
Task changes should be observable. Possible event types:
task_created
task_updated
task_started
task_blocked
task_completed
task_failed
task_cancelled
task_reopened
task_resume_classified
task_repaired
Each event should include:
- task id;
- session id;
- run id if available;
- previous status;
- next status;
- reason/evidence;
- timestamp.
Resume Behavior
On resume or startup recovery, task state should be classified conservatively.
Suggested trust levels:
trusted: terminal state has durable evidence and linked events are intact.needs_revalidation: state may still be correct but depends on external files, tests, or tool outputs that should be checked again.stale: task was in progress when the run/session was interrupted.repaired: recovery logic changed the task projection.untrusted: event log is corrupt, missing, or internally inconsistent.
Examples:
completedwith linked test result and unchanged artifact refs ->trusted.in_progresswhen app crashed ->stale.blockeddue to permission prompt before restart ->needs_revalidation.- task references a missing run/tool/artifact ->
untrusted. - recovery fixes an invalid transition ->
repaired.
Relationship To Other Roadmap Items
This task model can become a shared foundation for:
- resume: knowing what work can continue;
- observability: explaining what happened;
- dynamic workflow: adding dependencies and retry later;
- cron / automation: scheduled runs can create or update tasks later;
- multi-agent collaboration: assignment/handoff can build on task records later;
- AHE / benchmark loop: task traces can become evidence.
But this issue should not implement those higher-level systems.
Possible PR Split
- RFC / docs only: define task record, statuses, transition rules, evidence rules, and resume classification.
- Type definitions and validators.
- Task event projection on top of existing runtime/session storage.
- Minimal task tool surface behind a feature flag:
task_createtask_updatetask_list- optional
task_get
- Basic UI/trace display for current task, blocked reason, and completion evidence.
- Recovery tests for interrupted, corrupt, stale, and contradictory task states.
Acceptance Criteria
- A minimal task lifecycle contract is documented.
- Task statuses and allowed transitions are clearly defined.
- Completed / blocked / failed states require evidence or reason fields.
- Task records can link to session/run/tool/artifact references.
- Resume trust classification is defined.
- The design does not treat tasks as subagent dispatch.
- The design does not require a large project-management UI.
- Future workflow, automation, and multi-agent work can build on the same task state model.
中文版本
背景
#544 提出 Maka 后续要朝着“长期可恢复、可观察、可编排的 agent 平台”演进。
其中一个 roadmap 项是 Task model hardening:
收紧 task 状态、claim/review/done 流程、artifact 关联、失败原因、owner 和 assignee 语义。
这个 issue 聚焦在一个最小可用的 durable task model:它应该能支撑长期 agent 工作、恢复、可观测性和未来 workflow 编排,但不应该变成 UI-only checklist,也不应该变成 subagent 派发队列。
问题
一次长 agent 工作里通常包含很多隐式任务,但如果这些进度没有结构化 runtime state,Maka 就很难可靠回答:
- 当前正在做哪个 task?
- 哪些 task 已完成、阻塞、失败或仍待处理?
- 什么证据证明 task 已完成?
- task 为什么被阻塞?
- 哪个 run/tool/artifact 产生了相关证据?
- 中断或重启后,哪些 task 状态仍然可信?
自由文本 checklist 可以帮助模型推理,但它不足以作为 durable platform contract。
目标
定义一个最小 durable task lifecycle model。
这个模型应该:
- 提供类型化 task record;
- 定义允许的状态流转;
- 对 completed / blocked / failed 状态要求证据或原因;
- 关联 session/run/tool/artifact references;
- 支持中断后的保守 resume 行为;
- 可以通过 runtime events 或 trace projections 被观测;
- 独立于 subagent dispatch;
- 独立于重型项目管理 UI。
非目标
这个 issue 不打算:
- 构建完整 workflow engine;
- 实现 multi-agent assignment;
- 实现 cron / automation scheduling;
- 替换现有 AgentRun 或 RuntimeEvent 模型;
- 创建大型项目管理 UI;
- 让 task status 的权威性高于 filesystem、git、test 或 tool evidence;
- 把 task 当作 permission boundary。
建议的 Task Record
type TaskStatus =
| "pending"
| "in_progress"
| "blocked"
| "completed"
| "failed"
| "cancelled";
interface AgentTask {
id: string;
sessionId: string;
parentTaskId?: string;
title: string;
description?: string;
status: TaskStatus;
createdAt: string;
updatedAt: string;
owner?: "main_agent" | "user" | "system";
assignee?: string;
currentRunId?: string;
relatedRunIds?: string[];
relatedToolCallIds?: string[];
artifactRefs?: string[];
blockedReason?: string;
failureReason?: string;
completionEvidence?: string;
resumeTrust?: "trusted" | "needs_revalidation" | "stale" | "repaired" | "untrusted";
}这个模型有意保持很小。只有当具体 workflow 需要时,再新增字段。
状态语义
建议状态含义:
pending:已声明,但尚未开始。in_progress:正在处理。blocked:因为外部输入、缺失依赖、权限、前置步骤失败等原因无法继续。completed:已完成,并有证据。failed:已经尝试,但以失败结束,并有失败原因。cancelled:被主动取消,不应该自动恢复执行。
状态流转规则
建议允许的状态流转:
pending -> in_progress
pending -> cancelled
in_progress -> blocked
in_progress -> completed
in_progress -> failed
in_progress -> cancelled
blocked -> in_progress
blocked -> cancelled
blocked -> failed
failed -> pending
failed -> cancelled
completed -> in_progress only if explicitly reopened
cancelled -> pending only if explicitly reopened
非法状态流转应该被拒绝,或被记录为 repair event。
证据规则
部分状态必须带证据或原因:
blocked需要blockedReason。failed需要failureReason。completed需要completionEvidence。
证据应尽量使用 durable references:
- tool call id;
- run id;
- file/artifact ref;
- test command result;
- user confirmation;
- verifier/scorer result;
- diff or patch ref。
task 被标记为 completed 不代表它可以覆盖现实状态。如果后续 filesystem/git/test evidence 与 completed 状态冲突,resume 时应该把它标记为 needs_revalidation,或者重新打开。
Runtime Events
task 变化应该可观测。可能的事件类型:
task_created
task_updated
task_started
task_blocked
task_completed
task_failed
task_cancelled
task_reopened
task_resume_classified
task_repaired
每个事件应该包含:
- task id;
- session id;
- run id,如果可用;
- previous status;
- next status;
- reason/evidence;
- timestamp。
Resume 行为
在 resume 或 startup recovery 时,task 状态应该被保守分类。
建议 trust levels:
trusted:terminal state 有 durable evidence,且关联事件完整。needs_revalidation:状态可能仍然正确,但依赖外部文件、测试或 tool output,需要重新检查。stale:run/session 中断时 task 正在进行中。repaired:恢复逻辑修改过 task projection。untrusted:event log 损坏、缺失或内部不一致。
例子:
completed有关联 test result,且 artifact refs 未变化 ->trusted。- app 崩溃时 task 是
in_progress->stale。 - task 因 permission prompt 阻塞,随后 app 重启 ->
needs_revalidation。 - task 引用了缺失的 run/tool/artifact ->
untrusted。 - recovery 修复了非法状态流转 ->
repaired。
与其他 Roadmap 项的关系
这个 task model 可以成为以下能力的共同基础:
- resume:判断哪些工作可以继续;
- observability:解释发生了什么;
- dynamic workflow:后续增加依赖和 retry;
- cron / automation:scheduled run 后续可以创建或更新 task;
- multi-agent collaboration:assignment/handoff 后续可以建立在 task record 上;
- AHE / benchmark loop:task traces 可以成为 evidence。
但这个 issue 不应该实现这些更上层系统。
可能的 PR 拆分
- RFC / docs only:定义 task record、状态、流转规则、证据规则和 resume classification。
- 类型定义和 validators。
- 基于现有 runtime/session storage 的 task event projection。
- feature flag 下的最小 task tool surface:
task_createtask_updatetask_list- optional
task_get
- 基础 UI/trace 展示:当前 task、blocked reason、completion evidence。
- recovery tests:覆盖 interrupted、corrupt、stale、contradictory task states。
验收标准
- 最小 task lifecycle contract 已文档化。
- task 状态和允许的状态流转已清楚定义。
- completed / blocked / failed 状态必须带 evidence 或 reason。
- task record 可以关联 session/run/tool/artifact references。
- resume trust classification 已定义。
- 设计不把 task 当作 subagent dispatch。
- 设计不要求大型项目管理 UI。
- 未来 workflow、automation 和 multi-agent 工作可以构建在同一套 task state model 上。
Activity
somewan820 commentedon Jul 6, 2026
Implementation Plan
Phase 1 — Contract and invariants
Define the task lifecycle contract before wiring it into runtime behavior.
Deliverables:
AgentTask,TaskStatus, andResumeTrust;completed,blocked, andfailed;Acceptance criteria:
Phase 2 — Types and validators
Add source-backed TypeScript types and pure validation helpers.
Deliverables:
Possible APIs:
Acceptance criteria:
Phase 3 — Task event model
Represent task lifecycle changes as observable events.
Deliverables:
define task runtime event types:
define event payload shape;
add projection logic from task events to latest task state;
add tests for event replay and invalid event sequences.
Acceptance criteria:
Phase 4 — Storage / projection integration
Persist task state through the existing session/run storage model without replacing AgentRun or RuntimeEvent.
Deliverables:
Acceptance criteria:
Phase 5 — Minimal task tool surface behind a feature flag
Expose the smallest model-facing task tools only after the storage and validation contract exists.
Deliverables:
add feature-flagged tools:
enforce validators inside tool handlers;
emit task events from tool operations;
return compact task summaries to the model.
Acceptance criteria:
Phase 6 — Resume, trace, and UI/read-model polish
Make task state useful for users and for recovery/debugging.
Deliverables:
Acceptance criteria:
somewan820 commentedon Jul 6, 2026
Implementation Notes
This PR #567 hardens the existing session-scoped task ledger instead of introducing a second task/workflow system.
Implemented:
pending,in_progress,blocked,completed,failed,cancelled.blockedReasonfailureReasoncompletionEvidencetask-events.jsonland replay projection.tasks.jsonas legacy/projection cache.task_imported.task_list/task_get.resumeTrust.resumeTrust: "untrusted"fallback cache tasks from model-visible outputs.docs/durable-task-lifecycle.md.