Auto-clear completed task lists on new prompt#512
Merged
Conversation
When a new prompt is sent and all tasks in the task list are done, automatically clear the list so the model starts fresh. The cleared state is sent to the client as a synthetic toolCalled event, reusing the existing task-details rendering path. No protocol or client changes.
d119c43 to
f98c228
Compare
There was a problem hiding this comment.
Pull request overview
Implements automatic task-list cleanup at the start of a new chat prompt: if the current task list exists and all tasks are :done, the server clears the task state and emits a synthetic toolCalled event so clients re-render via the existing task-details UI path (no client changes intended).
Changes:
- Add
task/auto-clear-completed!plus tests for when auto-clear should/shouldn’t trigger. - Invoke auto-clear during
chat/promptand emit a synthetic:toolCalledevent to clients. - Update the task tool prompt guidance and add an Unreleased changelog entry.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/eca/features/tools/task.clj |
Adds auto-clear detection + mutation for fully-completed task lists. |
src/eca/features/chat.clj |
Calls auto-clear before prompt* and sends a synthetic toolCalled event with task details. |
test/eca/features/tools/task_test.clj |
Adds unit tests covering auto-clear behavior across done/pending/in-progress/empty/no-task-list cases. |
resources/prompts/tools/task.md |
Removes instruction telling the model to manually clear when all tasks are done. |
CHANGELOG.md |
Documents the new auto-clear behavior under Unreleased. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+268
to
+274
| (defn auto-clear-completed! | ||
| "Clear the task list when all tasks are done. | ||
| Returns task-details of the cleared state if clearing occurred, nil otherwise." | ||
| [db* chat-id] | ||
| (when (all-tasks-done? (get-task @db* chat-id)) | ||
| (mutate-task! db* chat-id (fn [_] {:state empty-task})) | ||
| (task-details empty-task))) |
Comment on lines
+1657
to
+1663
| (when-let [cleared-details (f.tools.task/auto-clear-completed! db* chat-id)] | ||
| (logger/info logger-tag "Auto-cleared completed task list" {:chat-id chat-id}) | ||
| (lifecycle/send-content! base-chat-ctx :assistant | ||
| {:type :toolCalled | ||
| :server "eca" | ||
| :name "task" | ||
| :details cleared-details})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a new prompt is sent and all tasks in the task list are done, automatically clear the list so the model starts fresh. The cleared state is sent to the client as a synthetic toolCalled event, reusing the existing task-details rendering path. No protocol or client changes.