From da46d3010c6d71382d5902c4c4ef5067fc02c17e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 16 Jul 2026 22:44:33 +0000 Subject: [PATCH] Consolidate todo remaining item filtering Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- agent/harness/todo/todo.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/agent/harness/todo/todo.go b/agent/harness/todo/todo.go index f2db516e..fee13e1a 100644 --- a/agent/harness/todo/todo.go +++ b/agent/harness/todo/todo.go @@ -137,13 +137,7 @@ func (p *Provider) GetRemainingItems(opts ...agent.Option) []Item { mu.Lock() defer mu.Unlock() st := p.loadState(opts) - var remaining []Item - for _, item := range st.Items { - if !item.IsComplete { - remaining = append(remaining, item) - } - } - return remaining + return remainingItems(st.Items) } func (p *Provider) loadState(opts []agent.Option) *state { @@ -313,13 +307,7 @@ func (p *Provider) createTools(opts []agent.Option) []tool.FuncTool { mu.Lock() defer mu.Unlock() st := p.loadState(opts) - var remaining []Item - for _, item := range st.Items { - if !item.IsComplete { - remaining = append(remaining, item) - } - } - return remaining, nil + return remainingItems(st.Items), nil }, ) @@ -340,6 +328,16 @@ func (p *Provider) createTools(opts []agent.Option) []tool.FuncTool { return []tool.FuncTool{addTool, completeTool, removeTool, getRemainingTool, getAllTool} } +func remainingItems(items []Item) []Item { + var remaining []Item + for _, item := range items { + if !item.IsComplete { + remaining = append(remaining, item) + } + } + return remaining +} + func formatTodoListMessage(items []Item) string { if len(items) == 0 { return "### Current todo list\n- none yet"