Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
feat(daemon): learn from complete recent discussions during memory review
Gus7e86b21f8240
diff --git a/src/daemon/src/manager/agentRouter.test.ts b/src/daemon/src/manager/agentRouter.test.tsindex 2c6046691..1aab4d867 100644--- a/src/daemon/src/manager/agentRouter.test.ts+++ b/src/daemon/src/manager/agentRouter.test.ts@@ -432,6 +432,13 @@ describe("AgentRouter — agent:reset", () => {expect(resets[0].rewakePrompt).toContain("Communicate task-relevant results, questions, and blockers normally");expect(resets[0].rewakePrompt).toContain("If nothing needs a user-facing response, send no message");expect(resets[0].rewakePrompt).toContain("resume outstanding work and handle your inbox messages");+ expect(resets[0].rewakePrompt).toContain("3. Learn: Use .context_timeline to find channels and threads you recently participated in");+ expect(resets[0].rewakePrompt).toContain("the full history of each recent discussion, from the initial request through the work, intermediate corrections, and any final decisions");+ expect(resets[0].rewakePrompt).toContain("the user's guidance on communication, collaboration, and how to do work");+ expect(resets[0].rewakePrompt).toContain("the underlying goals, reasons, and constraints");+ expect(resets[0].rewakePrompt).toContain("Preserve its scope and source links");+ expect(resets[0].rewakePrompt).toContain("distinguish explicit user instructions from your own inferences");+ expect(resets[0].rewakePrompt).toContain("Update or remove superseded notes");// Ordering: onBeforeAgent completes before resetSession fires.expect(order[0]).toBe("before:a1");expect(order[1]).toBe("reset:a1");@@ -504,6 +511,13 @@ describe("AgentRouter — machine:reset_all (batch reset)", () => {// Every entry reset, once each; onBeforeAgent ran for each (gate inherited).expect(resets.map((r) => r.agentId)).toEqual(["a1", "a2", "a3"]);for (const { rewakePrompt } of resets) {+ expect(rewakePrompt).toContain("3. Learn: Use .context_timeline to find channels and threads you recently participated in");+ expect(rewakePrompt).toContain("the full history of each recent discussion, from the initial request through the work, intermediate corrections, and any final decisions");+ expect(rewakePrompt).toContain("the user's guidance on communication, collaboration, and how to do work");+ expect(rewakePrompt).toContain("the underlying goals, reasons, and constraints");+ expect(rewakePrompt).toContain("Preserve its scope and source links");+ expect(rewakePrompt).toContain("distinguish explicit user instructions from your own inferences");+ expect(rewakePrompt).toContain("Update or remove superseded notes");expect(rewakePrompt).toContain("internal maintenance; perform it silently");expect(rewakePrompt).toContain("Do not proactively send the owner, users, or channels progress updates, completion notices, or details about your memory state");}diff --git a/src/daemon/src/manager/agentRouter.ts b/src/daemon/src/manager/agentRouter.tsindex 9a922eea5..179e2389d 100644--- a/src/daemon/src/manager/agentRouter.ts+++ b/src/daemon/src/manager/agentRouter.ts@@ -148,7 +148,8 @@ const REWAKE_PROMPT = `Your session was reset by your owner. Prior conversation1. Consistency: Read memory.md and experiences. Merge duplicates and resolve conflicting notes against original decisions. Check links.2. Facts: Verify claims, especially work progress, against the latest original records. Search the context timeline and task discussions through their latest outcomes. Correct outdated or unsupported claims; keep uncertainty explicit.-3. Durability: Keep only lasting facts, preferences, and reusable lessons or procedures. Remove task status, milestones, temporary plans, and diaries; extract a reusable lesson only when useful. Keep memory.md brief with links; put procedures, scope, and reasons in experiences. Reason from first principles: distill specific events into underlying causes, constraints, and reusable principles. Omit incidental dates and details; retain context only when it changes the principle’s validity or scope.+3. Learn: Use .context_timeline to find channels and threads you recently participated in. Read the full history of each recent discussion, from the initial request through the work, intermediate corrections, and any final decisions. Understand the sequence of events and why the user corrected the approach before learning first principles. Proactively record the user's guidance on communication, collaboration, and how to do work. Distill it into first principles: the underlying goals, reasons, and constraints that make the guidance reusable. Preserve its scope and source links; distinguish explicit user instructions from your own inferences. Update or remove superseded notes.+4. Durability: Keep only lasting facts, preferences, and reusable lessons or procedures. Remove task status, milestones, temporary plans, and diaries; extract a reusable lesson only when useful. Keep memory.md brief with links; put procedures, scope, and reasons in experiences. Reason from first principles: distill specific events into underlying causes, constraints, and reusable principles. Omit incidental dates and details; retain context only when it changes the principle’s validity or scope.Edit only your own memory files. This review is internal maintenance; perform it silently. Do not proactively send the owner, users, or channels progress updates, completion notices, or details about your memory state. Communicate task-relevant results, questions, and blockers normally. If nothing needs a user-facing response, send no message.diff --git a/src/daemon/src/manager/managerRuntime.test.ts b/src/daemon/src/manager/managerRuntime.test.tsindex 5ee360e47..834de940d 100644--- a/src/daemon/src/manager/managerRuntime.test.ts+++ b/src/daemon/src/manager/managerRuntime.test.ts@@ -480,6 +480,13 @@ describe("AgentProcessManager — idle memory maintenance", () => {await first.fire("runtime_event", { kind: "turn_end", sessionId: "saved-session" });}const deliveredPrompt = hibernated ? factory.mock.calls[1][0].ctx.prompt : send.mock.calls[0][0].text;+ expect(deliveredPrompt).toContain("3. Learn: Use .context_timeline to find channels and threads you recently participated in");+ expect(deliveredPrompt).toContain("the full history of each recent discussion, from the initial request through the work, intermediate corrections, and any final decisions");+ expect(deliveredPrompt).toContain("the user's guidance on communication, collaboration, and how to do work");+ expect(deliveredPrompt).toContain("the underlying goals, reasons, and constraints");+ expect(deliveredPrompt).toContain("Preserve its scope and source links");+ expect(deliveredPrompt).toContain("distinguish explicit user instructions from your own inferences");+ expect(deliveredPrompt).toContain("Update or remove superseded notes");expect(deliveredPrompt).toContain("internal maintenance; perform it silently");expect(deliveredPrompt).toContain("Do not proactively send the owner, users, or channels progress updates, completion notices, or details about your memory state");expect(deliveredPrompt).toContain("Communicate task-relevant results, questions, and blockers normally");diff --git a/src/daemon/src/manager/memoryMaintenancePrompt.ts b/src/daemon/src/manager/memoryMaintenancePrompt.tsindex c08eda2e4..10634925f 100644--- a/src/daemon/src/manager/memoryMaintenancePrompt.ts+++ b/src/daemon/src/manager/memoryMaintenancePrompt.ts@@ -2,7 +2,8 @@ export const MEMORY_MAINTENANCE_PROMPT = `The daemon is preparing to reset this1. Consistency: Read memory.md and experiences. Merge duplicates and resolve conflicting notes against original decisions. Check links.2. Facts: Verify claims, especially work progress, against the latest original records. Search the context timeline and task discussions through their latest outcomes. Correct outdated or unsupported claims; keep uncertainty explicit.-3. Durability: Keep only lasting facts, preferences, and reusable lessons or procedures. Remove task status, milestones, temporary plans, and diaries; extract a reusable lesson only when useful. Keep memory.md brief with links; put procedures, scope, and reasons in experiences. Reason from first principles: distill specific events into underlying causes, constraints, and reusable principles. Omit incidental dates and details; retain context only when it changes the principle’s validity or scope.+3. Learn: Use .context_timeline to find channels and threads you recently participated in. Read the full history of each recent discussion, from the initial request through the work, intermediate corrections, and any final decisions. Understand the sequence of events and why the user corrected the approach before learning first principles. Proactively record the user's guidance on communication, collaboration, and how to do work. Distill it into first principles: the underlying goals, reasons, and constraints that make the guidance reusable. Preserve its scope and source links; distinguish explicit user instructions from your own inferences. Update or remove superseded notes.+4. Durability: Keep only lasting facts, preferences, and reusable lessons or procedures. Remove task status, milestones, temporary plans, and diaries; extract a reusable lesson only when useful. Keep memory.md brief with links; put procedures, scope, and reasons in experiences. Reason from first principles: distill specific events into underlying causes, constraints, and reusable principles. Omit incidental dates and details; retain context only when it changes the principle’s validity or scope.Edit only your own memory files. This review is internal maintenance; perform it silently. Do not proactively send the owner, users, or channels progress updates, completion notices, or details about your memory state. Communicate task-relevant results, questions, and blockers normally. If nothing needs a user-facing response, send no message.