Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix: email task self-talking

Gus4474a64bbff5
diff --git a/src/cli/daemon/prompt.test.ts b/src/cli/daemon/prompt.test.ts
index 1ad42c022..6902eaefa 100644
--- a/src/cli/daemon/prompt.test.ts
+++ b/src/cli/daemon/prompt.test.ts
@@ -38,4 +38,19 @@ describe("buildPrompt", () => {
JSON.stringify({ type: "email_inbound", instruction: "Check inbox" }),
);
});
+
+ it("adds notice for email_notification tasks", () => {
+ const task = makeTask("New email from [email protected]: Hi", "email_notification");
+ const parsed = JSON.parse(buildPrompt(task));
+ expect(parsed.notice).toContain("no human in this session");
+ expect(parsed.notice).toContain("email sending tool");
+ expect(parsed.notice).toContain("send them an email asking for it and then exit");
+ expect(parsed.notice).toContain("new task will be triggered automatically");
+ });
+
+ it("does not add notice for non-email tasks", () => {
+ const task = makeTask("Fix the bug", "user_dm_message");
+ const parsed = JSON.parse(buildPrompt(task));
+ expect(parsed.notice).toBeUndefined();
+ });
});
diff --git a/src/cli/daemon/prompt.ts b/src/cli/daemon/prompt.ts
index 5ea91338f..f379c95bd 100644
--- a/src/cli/daemon/prompt.ts
+++ b/src/cli/daemon/prompt.ts
@@ -1,7 +1,16 @@
import type { Task, Attachment } from "./types.js";
+const EMAIL_NOTICE =
+ "This task was triggered automatically by an incoming email. There is no human in this session." +
+ " If you need to communicate with a human, you MUST send an email using the email sending tool." +
+ " If you need more information or confirmation from the human, send them an email asking for it and then exit." +
+ " Do not wait — when the human replies, a new task will be triggered automatically and you will be woken up with their response.";
+
export function buildPrompt(task: Task, attachments?: Attachment[]): string {
const obj: Record<string, unknown> = { type: task.type, instruction: task.prompt };
+ if (task.type === "email_notification") {
+ obj.notice = EMAIL_NOTICE;
+ }
if (attachments && attachments.length > 0) {
obj.attachments = attachments.map((a) => ({
path: a.path,