Repository navigation
long running tasks todolist
A session-scoped, lightweight planning and enforcement layer built on top of the existing TaskFlow system. It is not a task engine, not a DAG, and does not implement a scheduler. Session-level plans are managed by
todowrite/todoread(compression-immune via the per-turn system-reminder block). Cross-session, durable, subagent-dispatching execution is owned by TaskFlow (depends_on,blocked/ready/dispatched/done,taskflow_step(action="dispatch"),taskflow_step(action="wait_all")). The two layers are linked byflow_id/step_id; a single state has one authoritative source — no cross-layer duplication.
- Positioning: Relationship with TaskFlow
- Design Philosophy & Core Principles
- Architecture Overview
- Data Layer
- Service Layer
- Tool Layer
- Orchestration Execution Layer
- Compression Protection Layer
-
Enforcement Layer E1–E7
- E1: System Prompt Enforcement — Orchestrator Doctrine
- E2: Tool Description Enforcement — Format + Delegation Rules
- E3: Continuation Enforcer — Post-Turn Closure Core ★★
- E4: Transition Barrier — Dual Insurance
- E5: Sisyphus doctrine (prompt-only; runtime gate is completion drain) ★★
- E6: Delegation Routing — Todo & Subagent Linkage ★
- E7: Intent Recognition & Guidance — Pre-Trigger ★★
- Frontend
| Dimension | Session Plan / Checklist | Execution Flow (DAG) |
|---|---|---|
| Owner | Planning & Discipline Layer (this doc) | TaskFlow (existing system) |
| Scope | Single session, lightweight | Cross-session, durable |
| State | todo content/status/priority/category/delegation
|
step depends_on/status/child_session_key/results
|
| Persistence |
registry.db (todos table) |
registry.db (task_flows table) + flow state_json
|
| Injection | System prompt block (rebuilt after every compression, naturally immune) | Tool return text (taskflow_inspect(action="summary") re-read) |
| Main duty | Planning, visibility, discipline enforcement (E1–E7) | Dependency satisfaction, block/unlock, parallel dispatch, bounded wait, result injection |
| Scheduling? | No | Yes (taskflow_step(action="run_task") / taskflow_step(action="dispatch") / taskflow_step(action="wait_all") / taskflow_step(action="resume")) |
One-liner: the planning & discipline layer is responsible for "think clearly, keep track, force completion"; TaskFlow is responsible for "actually run, cross-session, manage dependencies".
| Concern | Authority | Notes |
|---|---|---|
| Whether a todo is complete | registry.db |
Only todowrite can change todo status |
| Whether a step is complete / deps satisfied | TaskFlow state_json
|
Only taskflow_step(action="resume") can mark a step done and unlock successors |
| Whether a child session is still running | subagent registry |
get_run_by_child_session_key + is_live_unended_run
|
| Plan file progress (checkboxes) | workspace/sessions/<id>/plans/*.md |
Orchestrator edits - [ ] → - [x]
|
| Execution evidence |
src/data/registry.db (evidence_events table) |
SQLite EvidenceLedger (shared, WAL, retention/purge) |
| Active work state | src/data/boulder.json |
Plan activation/recovery |
A todo may carry two optional fields pointing to TaskFlow:
-
flow_id: the linked TaskFlow flow id. -
step_id: the linked TaskFlow step id (e.g.step-2), for re-reading that step's DAG status.
The no-mirroring principle:
- The todo layer does not copy
depends_on, does not store a DAG/wave projection, does not cache step status. - When DAG status is needed, call the read-only
taskflow_inspect(action="summary", flow_id)and mapblocked/ready/dispatched/doneback to the UI/prompt. - When advancing the DAG, call TaskFlow tools; the todo layer only updates the corresponding todo status.
Adopts the HTN (Hierarchical Task Network) paradigm: plan file → checkbox → atomic sub-task → delegate to subagent workers → adversarial verification.
Plan (workspace/sessions/<id>/plans/*.md)
└─ Wave 0: [Checkbox A] [Checkbox B] ← parallel, no dependencies
└─ Wave 1: [Checkbox C] (depends on A, B) ← wait for Wave 0
└─ Wave 2: [Final Verification Wave] ← global wrap-up
Each Checkbox → decomposed into atomic sub-tasks → delegated to subagent workers
└─ Worker returns DoneClaim
└─ AdversarialVerify (independent verification)
└─ FullyDone → mark checkbox complete
The "Wave" here is a narrative unit in the plan file, not a todolist scheduling data structure. "When can the next step be dispatched" is determined by TaskFlow's depends_on + blocked/ready status.
Core principle (ulw-execute/SKILL.md:6-8):
YOU ARE AN ORCHESTRATOR — NEVER THE IMPLEMENTER. YOU DO NOT WRITE CODE. YOU DO NOT EDIT PRODUCT FILES. EVERY unit of implementation MUST be delegated to a spawned subagent.
Does not rely on model self-discipline. A 7-layer enforcement forms a closed loop:
Before (message arrives) During After
┌──────────┐ ┌────────────────────┐ ┌──────────────────────┐
│ E7 Intent │ │ E6 Delegation ★ │ │ E3 Continuation ★★ │
│ Recognizer│ │ #a fan-out │ │ idle + incomplete │
│ ★★ │ │ #b category route │ │ todo + backoff + │
│ before_ │ │ #c delegation cmd │ │ stagnation + abort │
│ model │ │ #d barrier │ │ + recovery mode │
│ inject │ └────────────────────┘ └──────────────────────┘
└──────────┘ ┌────────────────────┐ ┌──────────────────────┐
┌──────────┐ │ E1 System prompt │ │ E5 Sisyphus verify ★★│
│ E2 Tool │ │ orchestrator │ │ DoneClaim → │
│ desc │ │ doctrine │ │ AdversarialVerify → │
│ MANDATORY │ │ + hook notice │ │ FullyDone │
│ format │ └────────────────────┘ └──────────────────────┘
└──────────┘ ┌──────────────────────┐
│ E4 Transition barrier│
│ TaskFlow step status+│
│ subagent alive → block│
└──────────────────────┘
One-liner: model won't plan → E7 injects guidance; model stops lazily → E3 pulls back; model fakes completion → E5 blocks; model writes code itself → E1 doctrine deters; model marks done early → E4 hard-blocks.
Layer 9 │ UI Component │ ProgressFloat.vue (PrimeVue), grouped by TaskFlow flow
Layer 8 │ Frontend State │ useTodoList.ts (module singleton) + grouped by flow
Layer 7 │ Realtime Comm │ WS: todo_updated push + todo_refresh reconnect
Layer 6 │ Compression Guard │ DynamicReminderMiddleware injects current todos + boulder as per-turn reminders
Layer 5 │ DAG Execution │ Provided by TaskFlow: depends_on + blocked/ready/dispatched/done
Layer 4 │ Orchestration │ ulw-execute: plan→checkbox→sub-task→worker→verify, calls TaskFlow
Layer 3 │ Tools │ todowrite + todoread (DAG executed by taskflow_* tool family)
Layer 2 │ Service │ TodoService (EvidenceLedger moved to `pub_base/`, shared; DAG queries delegated to TaskFlow)
Layer 1 │ Data Storage │ registry.db (WAL, todos + evidence tables) + boulder.json + plans/*.md
─────────│──────────────────│
E1 │ System Prompt │ AGENTS.md: MANDATORY orchestrator doctrine
E2 │ Tool Description │ todowrite docstring format rules
E3 │ Continuation ★★ │ after_agent middleware: idle+incomplete→auto-continue
E4 │ Transition Barrier│ TaskFlow step not done / subagent running → block completed
E5 │ Sisyphus Verify │ Doctrine only: DoneClaim → AdversarialVerify → FullyDone (runtime gate = evidence drain)
E6 │ Delegation Route │ #a fan-out + #b category route + #c delegation cmd + #d barrier
E7 │ Intent Recognizer│ before_model: arming (no plan + task intent) + plan-active reminder
Layer 5's DAG capability is NOT implemented by this layer — it is provided by TaskFlow (agent/tools/taskflow/tools/*). This layer only calls, never rebuilds.
class TodoService:
@staticmethod
async def update_todos(session_id: str, todos: list[dict]) -> list[dict]:
validated = _validate_todos(todos)
# E4: Transition barrier — block completed when TaskFlow step not done / subagent running
for todo in validated:
if todo["status"] == "completed":
_assert_transition_allowed(todo)
await store.replace_all(session_id, validated)
latest = await store.get_todos(session_id)
await _push_todo_update(session_id, latest)
return latest
@staticmethod
async def get_flow_progress(session_id: str, flow_id: str) -> dict:
"""Map TaskFlow's DAG status back to a todo view (does not recompute frontier).
DAG scheduling lives in TaskFlow; this method only calls read-only taskflow_summary."""
from agent.tools.taskflow.tools.taskflow_summary import taskflow_summary
linked = await store.get_todos_by_flow(session_id, flow_id)
summary_text = await taskflow_summary.ainvoke({"flow_id": flow_id, "session_id": session_id})
return {"todos": linked, "summary": summary_text}agent/tools/pub_base/evidence_ledger.py is the SQLite store (src/data/registry.db (evidence_events table), WAL) behind the verification audit trail: append + read_all are the whole storage contract, every caller-facing row is immutable, and retention deletes old rows. Session-scoped views read the same shared DB. It moved out of todolist/ into pub_base/ and is shared by todolist, TaskFlow, terminal and the file tools — it is not a todolist-owned layer. The class API, the producers, the row schemas, the derived-staleness rule and the gates that consume the summary are documented in Evidence Ledger.
async def _push_todo_update(session_id: str, todos: list[dict]) -> None:
_sync_intent_anchor(session_id, todos) # plan ended -> clear the anchor
try:
await broadcast_to_session(session_id, {
"event": "todo_updated", "session_id": session_id,
"content": {"todos": todos}
}, ensure_ascii=False)
except Exception as e:
logger.warning("Failed to push todo_updated for session {}: {}", session_id, e)_push_todo_update is the single choke point for EVERY todo write
(update/add/patch/remove/complete/cancel/reattach). It now also owns the
anchor lifecycle: _sync_intent_anchor clears StateKey.PLAN_INTENT_ANCHOR
when the list is empty or every todo is terminal (completed/cancelled), so
a finished plan's intent cannot leak into the next task. While any todo —
including the verify todo — is still active, the anchor is retained; the verify
drift gate (plan_drifted, see E4)
runs before this write, so cleanup never disarms it.
Every todo carries a stable todo_id, rendered as #N in the system reminder and in read-back JSON. position is only the display order; local actions address todo_id, so an insertion never makes an id drift.
-
replace(default): pass the COMPLETEtodoslist. Every row gets a freshtodo_id. -
patch:todo_id+ any ofcontent/status/priority/category;flow_id/step_id/plan_refare preserved. -
add:content; omitafter_todo_idto append, or pass#Nto insert immediately after that todo. -
remove:todo_id. -
reattach:todo_id+flow_id; binds an existing todo as an orphan flow's GC root. -
list_orphans: lists active flows with no active todo root.
The tool returns the updated row/list as JSON and pushes todo_updated; a missing id returns the current valid list with #N markers so the model can retry.
@tool("todoread")
async def todoread(
session_id: Annotated[str, InjectedState("session_id")] = "",
) -> str:
"""Read the current todo list from database. Use when unsure of current state."""
todos = await service.get_todos(session_id)
return json.dumps(todos, ensure_ascii=False, indent=2) if todos else "No todos found."def build_todolist_tools() -> list[BaseTool]:
for t in _TODOLIST_TOOLS:
t.handle_tool_error = True
t.metadata = {"scope": "main_only"}
if t.name == "todowrite":
# add/remove are not repeat-safe; the other actions are.
t.metadata["idempotent_actions"] = (
"replace", "patch", "reattach", "list_orphans",
)
todowrite.description += _TODOWRITE_FORMAT_RULES # E2 format rules
return list(_TODOLIST_TOOLS)The skill file defines when to use todolist (3+ step work), available tools, status/priority/delegation fields, DAG fields (delegated to TaskFlow), and rules (prefer local actions; replace only for a full rewrite; one in_progress at a time; no marking completed before a subagent returns).
The model-facing knowledge tool is no longer registered; only internal KnowledgeStore audit/repair reads and writes remain. The historical storage layer (agent/tools/todolist/knowledge/) is keyed by plan identity, not by plan name. Association comes from three sources (ownership.association_plan_refs()): the session's plan_ref state key, a plan_ref on one of the session's todos (SQL filtered by session_id), and a src/data/boulder.json work whose plan_name matches and whose session_ids contains the session. identity.resolve_plan_identity() maps that name to the canonical plan path and derives the storage directory workspace/knowledge/plans/<plan_key>/, where plan_key = sha1(repo-relative plan path)[:12]; each directory carries a meta.json with the readable plan_name / plan_ref. Consequences:
- Same-named plans held in different plan files are physically isolated — each session writes its own key directory, so neither can overwrite the other;
- One plan file shared through boulder
session_idsresolves the same path for every listed session, so multi-session collaboration stays intact (one shared directory); - A session whose plan file does not resolve writes under the fallback identity
session-<sha1(session_id)[:8]>— hashing the full id keeps sessions whose ids share an 8-char prefix apart; -
plan_reftakes precedence when a name matches several paths; a name that stays ambiguous (and is not the session's own fallback) is refused with a diagnosable error, never silently written elsewhere.
list returns only the session's associated plans (readable name + key), and a foreign plan is refused on read / write (never a silent empty result). Legacy name-keyed workspace/knowledge/plans/<plan-name>/ directories stay readable until the key directory exists; writes always land in the key directory. clear_session deletes the session's private identity directories and retains plans shared with another session through boulder session_ids; legacy directories are never deleted. A missing/corrupt boulder file, an empty session_id, or an unknown plan all deny safely — no exception, no cross-session read.
Phase 1: Select the plan → read src/data/boulder.json, list workspace/sessions/<session_id>/plans/*.md, match or restore
Phase 2: Create/update Boulder state → write boulder.json, register phases/tasks as todos
Phase 3: Execute next checkbox (scheduling delegated to TaskFlow)
→ Find first unchecked checkbox
→ Decompose into atomic sub-tasks
→ Register as TaskFlow steps: taskflow_step(action="run_task", flow_id, task, depends_on=[...])
→ Blocked steps not dispatched; ready steps via taskflow_step(action="dispatch")
→ taskflow_step(action="wait_all") → taskflow_step(action="resume") (inject result, unlock successors)
→ DELEGATE EVERYTHING via delegation router (E6)
Phase 4: Verify and record evidence → 5 gates → `src/data/registry.db` (`evidence_events` table)
Phase 5: Mark progress → edit checkbox - [ ] → - [x], continue without asking
-
taskflow_flow(action="create", flow_id, description, initial_state)— create the flow. -
taskflow_step(action="run_task", flow_id, task, depends_on=[...])— register steps:- No deps → immediately
dispatched(child session spawned). - Deps unsatisfied →
blocked, not dispatched. Unknown dep id → error, no state change.
- No deps → immediately
-
taskflow_step(action="resume", flow_id, child_session_key, result)— inject result:- Step becomes
done; dependentblockedsteps unlock toready(returned). -
auto_dispatch=True(the default) spawns the whole ready set immediately; passauto_dispatch=Falseto only unlock.
- Step becomes
-
taskflow_step(action="dispatch", flow_id, step_ids)— batch parallel dispatch ready steps. -
taskflow_step(action="wait_all", flow_id, timeout, poll_interval)— wait for dispatched children to settle. -
taskflow_flow(action="finish", flow_id, summary)— wrap up;taskflow_inspect(action="summary")anytime for re-read.
blocked (deps not all done; run_task only registers, no spawn)
→ ready (deps satisfied, awaiting dispatch; unlocked by taskflow_step(action="resume"))
→ dispatched (detached child session spawned, child_session_key persisted)
→ done (result injected via taskflow_step(action="resume"))
| Plan-layer concept (HTN) | TaskFlow capability |
|---|---|
| Inter-checkbox dependencies | step depends_on (step-id list, e.g. ["step-1"]) |
| Wave / wave index | No explicit wave; ready status = "current wave" |
| Node status |
status ∈ {blocked, ready, dispatched, done} in state_json
|
| Frontier (executable items) |
ready status + taskflow_step(action="dispatch") validates deps_satisfied
|
| Block when deps unsatisfied |
taskflow_step(action="run_task", ..., depends_on=[...]) registers blocked, no spawn |
| Unlock successors on completion |
taskflow_step(action="resume") marks step done + unlock_dependents
|
| Parallel dispatch |
taskflow_step(action="dispatch", flow_id, step_ids) batch dispatch ready steps |
| Wait for parallel children |
taskflow_step(action="wait_all", ...) flow-scoped bounded poll |
| Re-read DAG status |
taskflow_inspect(action="summary", flow_id) renders per-step status + counts |
| Topology | Condition | Strategy |
|---|---|---|
| Independent channels → parallel workers | Separate files, no shared contracts | One parallel spawn burst (taskflow_step(action="dispatch")) |
| Ordered dependency channel → wave serial | C needs A and B first | Wait for predecessor done then execute (depends_on + resume unlock) |
| Overlapping channels → team | Same module/contract, concurrent faster | Serialize or manually coordinate |
The build_system_prompt() is re-called by the Summarization middleware after every context compression. Injecting current todos + boulder state here is naturally immune to compression.
| Block | Data source | Context cost | Description |
|---|---|---|---|
_build_todo_block() |
registry.db + StateKey.PLAN_INTENT_ANCHOR
|
~10 lines | Intent Anchor (if approved) + current todo list + status + TaskFlow flow/step association |
_build_boulder_block() |
src/data/boulder.json | ~5 lines | Active work state |
_build_knowledge_block() (retired) |
workspace/knowledge/plans/<plan_key>/ | — | Model-facing knowledge block is no longer injected |
def _build_todo_block(session_id: str) -> str:
todos = _read_todos_sync(session_id)
if not todos:
return ""
# The approved plan's INTENT rides with the working plan; guarded so a
# broken anchor can never drop the todo list itself.
anchor_text = ""
try:
anchor = read_intent_anchor(session_id) # workspace.intent_anchor_view
if anchor:
anchor_text = format_intent_anchor(anchor)
except Exception as error:
logger.debug("prompt builder: intent anchor read failed ({})", error)
lines = ["## Current Todo List"]
if anchor_text:
lines.append(anchor_text) # Goal / Must-have / Must-NOT-have / Accept
lines.append("")
for todo in todos:
icon = _TODO_ICONS.get(todo.get("status", ""), "○")
tag_parts = [todo.get("category") or "quick"]
delegation = todo.get("delegation")
if delegation and delegation != "self":
tag_parts.append(delegation)
if todo.get("flow_id"):
tag_parts.append(f"flow:{todo['flow_id']}")
if todo.get("step_id"):
tag_parts.append(todo["step_id"])
tag = f"({', '.join(tag_parts)})"
todo_id = todo.get("todo_id")
id_prefix = f"#{todo_id} " if todo_id else ""
lines.append(f"- [{icon}] {id_prefix}{tag} {todo['content']} ({todo.get('priority') or 'medium'})")
notes = str(todo.get("notes") or "").strip()
if notes:
lines.append(f" notes: {notes[:300]}")
lines.append(
"Your todo list is tracked by the continuation system. "
"Incomplete todos will trigger automatic continuation."
)
lines.append(
"Completion is verified by the Sisyphus contract — unverified claims will be rejected."
)
return "\n".join(lines)The Intent Anchor is rendered as one block (hash-deduplicated as a whole, not per todo), is absent from the system prompt (prefix-cache safe), and is re-injected after compression because the catalog's hash state is reset. See Plan mode §Intent anchor and E4 for the verify gate that checks it.
| omo's 5 layers | This approach |
|---|---|
| Prune protection list | Not needed (todos in the per-turn reminder block) |
| Pre-compression snapshot + post-compression restore | Not needed (system prompt rebuilt from DB each time) |
| 8-segment compression context injection | Not needed (todos not in conversation history) |
| 60s compression protection window | Not needed (no continuation injector to protect) |
| Continuation enforcer | Needed, simplified to after_agent middleware (E3) |
| Knowledge summary injection | New _build_knowledge_block() ~25 lines |
| Total ~600+ lines | ~65 lines (prompt injection) + ~130 lines (continuation middleware) |
Module-level singleton, WebSocket-driven, grouped by TaskFlow flow:
interface Todo {
content: string;
status: "pending" | "in_progress" | "completed" | "cancelled";
priority: "high" | "medium" | "low";
category?: "quick" | "deep" | "ultrabrain" | "visual" | "git" | "writing";
delegation?: "self" | "subagent";
subagent_id?: string | null;
flow_id?: string | null;
step_id?: string | null;
taskflow_status?: "blocked" | "ready" | "dispatched" | "done" | null;
}WS events: todo_updated (push on change) + todo_refresh (re-send on reconnect).
-
ProgressFloat.vue: the chat's plan float — todos grouped by
flow_idplus the TaskFlow flat step list, collapsed to a pill by default. Its expanded header opens the task board (TaskFlowBoardPanel.vue, a session-scoped right-sidebar tab) where each active flow's steps are laid into one swimlane per non-empty status; that is the only other plan surface (the old input-box dock was removed on purpose).
{
"event": "todo_updated",
"session_id": "xxx",
"content": {
"todos": [
{
"content": "Implement login",
"status": "completed",
"priority": "high",
"flow_id": "login-flow",
"step_id": "step-1",
"taskflow_status": "done"
}
]
}
}taskflow_status is the step status re-read from taskflow_inspect(action="summary", flow_id); the frontend does not recompute step dependencies.
Generated from the repository's wiki/ tree. Source