The Open Framework for Building Agents
fix(eve): skip terminal todo state during compaction (#1845)
vercel-gh-bot-5[bot]7449917cac9e
diff --git a/.changeset/quiet-terminal-todos.md b/.changeset/quiet-terminal-todos.mdnew file mode 100644index 000000000..20ad0c481--- /dev/null+++ b/.changeset/quiet-terminal-todos.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Stop completed and cancelled todo lists from being re-injected as user messages after compaction. Lists that still contain active work continue to be preserved in full.diff --git a/packages/eve/src/runtime/framework-tools/todo.test.ts b/packages/eve/src/runtime/framework-tools/todo.test.tsindex 93478246a..79911739e 100644--- a/packages/eve/src/runtime/framework-tools/todo.test.ts+++ b/packages/eve/src/runtime/framework-tools/todo.test.ts@@ -137,7 +137,7 @@ describe("getTodoCompactionMessage", () => {return contextStorage.run(ctx, () => getTodoCompactionMessage());}- it("returns a summary message for a non-empty list", () => {+ it("returns the full summary when the list contains active work", () => {const message = callHook({items: [{ content: "Fix bug", priority: "high", status: "completed" },@@ -154,6 +154,17 @@ describe("getTodoCompactionMessage", () => {expect(text).toContain("[-] [low] Cancelled task");});+ it("returns undefined when every item is terminal", () => {+ expect(+ callHook({+ items: [+ { content: "Fix bug", priority: "high", status: "completed" },+ { content: "Skip docs", priority: "low", status: "cancelled" },+ ],+ }),+ ).toBeUndefined();+ });+it("returns undefined for an empty list", () => {expect(callHook({ items: [] })).toBeUndefined();});diff --git a/packages/eve/src/runtime/framework-tools/todo.ts b/packages/eve/src/runtime/framework-tools/todo.tsindex 056e1b218..bae7bda86 100644--- a/packages/eve/src/runtime/framework-tools/todo.ts+++ b/packages/eve/src/runtime/framework-tools/todo.ts@@ -50,7 +50,12 @@ function formatTodoSummary(state: TodoState): string | undefined {*/export function getTodoCompactionMessage(): ModelMessage | undefined {const state = loadContext().get(TodoStateKey);- if (state === undefined || state.items.length === 0) return undefined;+ if (+ state === undefined ||+ !state.items.some((item) => item.status === "pending" || item.status === "in_progress")+ ) {+ return undefined;+ }const summary = formatTodoSummary(state);if (summary === undefined) return undefined;return { content: summary, role: "user" };