Skip to content

Commit 15c05d4

Browse files
committed
Add eca__todo tool for multi-step task planning and tracking
Introduces a new native tool `eca__todo` to help the agent plan, organize, and track progress across complex, multi-step tasks. - Maintains a persistent TODO state per chat in the DB - Supports operations: plan, add, update, start, complete, delete, clear - Includes dependency tracking (blocked_by) and cycle detection - Enforces sequential execution by default to prevent improper batching - Covered by comprehensive unit and integration tests
1 parent ef2924c commit 15c05d4

8 files changed

Lines changed: 1067 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Add Todo tool #246
6+
57
## 0.109.5
68

79
- Fix clear messages to reset usage tokens as well.

resources/prompts/code_agent.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,22 @@ You have tools at your disposal to solve the coding task. Follow these rules reg
2727
2. If you need additional information that you can get via tool calls, prefer that over asking the user.
2828
3. If you are not sure about file content or codebase structure pertaining to the user's request, use your tools to read files and gather the relevant information: do NOT guess or make up an answer.
2929
4. You have the capability to call multiple tools in a single response, batch your tool calls together for optimal performance.
30+
31+
{% if toolEnabled_eca__todo %}
32+
## TODO Tool
33+
34+
You have access to a `eca__todo` tool for tracking multi-step work within this chat.
35+
36+
### Workflow:
37+
1. Use `plan` to create TODO with goal and tasks
38+
2. Use `start` before working on a task (marks it as in_progress)
39+
3. Use `complete` only for tasks that are actually finished; for each targeted task that has `done_when`, verify it first.
40+
4. Use `add` if you discover additional work
41+
5. When a plan is fully completed and no further work is needed for the current goal, always use the `clear` operation to clean up the workspace.
42+
6. Delegate focused work to subagents when helpful. Work sequentially by default; batch operations ONLY for tasks executing simultaneously.
43+
44+
### done_when guidance:
45+
- `done_when` is optional.
46+
- Prefer setting it for non-trivial tasks where completion should be objectively verifiable.
47+
- For trivial tasks, you may omit it to keep tracking lightweight.
48+
{% endif %}

resources/prompts/tools/todo.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Task management for planning and tracking work.
2+
3+
When to Use:
4+
- Tasks requiring 3 or more distinct steps
5+
- User provides multiple tasks (numbered lists, comma-separated items)
6+
- Non-trivial work that benefits from planning and tracking
7+
- User explicitly requests task tracking or a todo list
8+
9+
When NOT to Use:
10+
- Single, trivial task completable in very few steps
11+
- Purely informational or conversational queries
12+
- Quick fixes where tracking adds no organizational value
13+
14+
Operations:
15+
- read: View current TODO state
16+
- plan: Create/replace TODO with goal and tasks (required: goal, tasks)
17+
- add: Append task(s) to existing TODO
18+
- update: Modify a single task metadata by `id` (content, priority, done_when, blocked_by) — cannot change status
19+
- start: Begin work on tasks by `ids` (sets to in_progress; rejects blocked or done tasks)
20+
- complete: Mark tasks by `ids` as done (verify done_when criteria first)
21+
- delete: Remove tasks by `ids`
22+
- clear: Reset entire TODO (removes goal and all tasks)
23+
24+
Workflow:
25+
1. Use 'plan' to create TODO with goal and initial tasks
26+
2. Use 'start' before working on a task — marks it as in_progress
27+
3. Work sequentially by default. Batch 'start' or 'complete' operations (using multiple 'ids') ONLY for independent tasks being executed simultaneously (e.g., via subagents).
28+
4. Use 'complete' only for tasks that are actually finished; for each targeted task that has `done_when`, verify it first — the response tells you which tasks got unblocked
29+
5. Use 'add' if you discover additional work during execution
30+
6. When a plan is fully completed and no further work is needed for the current goal, always use the 'clear' operation to clean up the workspace.
31+
32+
How to use done_when:
33+
- `done_when` is optional.
34+
- Use it for non-trivial tasks where completion must be verifiable (tests passing, behavior implemented, specific file changes, etc.).
35+
- For trivial/obvious tasks, you may omit `done_when` to avoid overhead.
36+
37+
Task Completion Integrity:
38+
- Mark tasks complete as soon as they are finished.
39+
- If a task has `done_when`, ONLY mark it as completed when ALL `done_when` criteria are actually met (for each task in a batch).
40+
- Do NOT complete if: tests failing, implementation partial, or errors unresolved.
41+
- When completing reveals follow-up work, use 'add' to append new tasks.

src/eca/db.clj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@
6060
:messages [{:role (or "user" "assistant" "tool_call" "tool_call_output" "reason")
6161
:content (or :string [::any-map]) ;; string for simple text, map/vector for structured content
6262
:content-id :string}]
63+
:todo {:goal :string
64+
:next-id :number
65+
:tasks [{:id :number
66+
:content :string
67+
:status (or :pending :in-progress :done)
68+
:priority (or :high :medium :low)
69+
:done-when (or :string nil)
70+
:blocked-by #{:number}}]}
6371
:tool-calls {"<tool-call-id>"
6472
{:status (or :initial :preparing :check-approval :waiting-approval
6573
:execution-approved :executing :rejected :cleanup

src/eca/features/tools.clj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
[eca.features.tools.mcp.clojure-mcp]
1414
[eca.features.tools.shell :as f.tools.shell]
1515
[eca.features.tools.skill :as f.tools.skill]
16+
[eca.features.tools.todo :as f.tools.todo]
1617
[eca.features.tools.util :as tools.util]
1718
[eca.logger :as logger]
1819
[eca.messenger :as messenger]
@@ -148,6 +149,7 @@
148149
f.tools.editor/definitions
149150
f.tools.chat/definitions
150151
f.tools.skill/definitions
152+
f.tools.todo/definitions
151153
(f.tools.agent/definitions config)
152154
(f.tools.custom/definitions config))))
153155

@@ -156,9 +158,11 @@
156158

157159
(defn ^:private filter-subagent-tools
158160
"Filter tools for subagent execution.
159-
Excludes spawn_agent to prevent nesting."
161+
162+
- Excludes spawn_agent to prevent nesting.
163+
- Excludes todo because TODO state is currently chat-local; it should be managed by the parent agent."
160164
[tools]
161-
(filterv #(not= "spawn_agent" (:name %)) tools))
165+
(filterv #(not (contains? #{"spawn_agent" "todo"} (:name %))) tools))
162166

163167
(defn all-tools
164168
"Returns all available tools, including both native ECA tools

0 commit comments

Comments
 (0)