Agent Zero AI framework
feat(email): add email_update tool for sending progress emails without ending agent loop
linuztx4ebb5f472cdb
diff --git a/plugins/_email_integration/extensions/python/system_prompt/_20_email_context.py b/plugins/_email_integration/extensions/python/system_prompt/_20_email_context.pyindex b2a8798f5..aa7d21215 100644--- a/plugins/_email_integration/extensions/python/system_prompt/_20_email_context.py+++ b/plugins/_email_integration/extensions/python/system_prompt/_20_email_context.py@@ -17,5 +17,9 @@ class EmailContextPrompt(Extension):returnif self.agent.context.data.get(CTX_EMAIL_HANDLER):- prompt = self.agent.read_prompt("fw.email.system_context_reply.md")- system_prompt.append(prompt)+ system_prompt.append(+ self.agent.read_prompt("fw.email.system_context_reply.md")+ )+ system_prompt.append(+ self.agent.read_prompt("fw.email.tool_email_update.md")+ )diff --git a/plugins/_email_integration/prompts/fw.email.system_context_reply.md b/plugins/_email_integration/prompts/fw.email.system_context_reply.mdindex d53d39a40..aaa6a52d0 100644--- a/plugins/_email_integration/prompts/fw.email.system_context_reply.md+++ b/plugins/_email_integration/prompts/fw.email.system_context_reply.md@@ -1,15 +1,17 @@## Email conversation-you are in an email conversation, user communicates via email+you are in an email conversation user communicates via emailyour response (via response tool) will be sent as email reply automatically-be concise, professional, clear+be concise professional cleardo not include email headers or signatures — they are added automatically-if task requires extended processing, provide brief status then continue work++### Progress updates+for long tasks use email_update tool to send progress emails without ending your task+use response tool only for the final answer### Sending file attachments-to attach files to your email reply, add `attachments` list with absolute file paths to the response tool:+to attach files to your email reply add attachments list with absolute file paths:~~~json{- ..."tool_name": "response","tool_args": {"text": "Here is the file you requested.",diff --git a/plugins/_email_integration/prompts/fw.email.tool_email_update.md b/plugins/_email_integration/prompts/fw.email.tool_email_update.mdnew file mode 100644index 000000000..3cbcbfa35--- /dev/null+++ b/plugins/_email_integration/prompts/fw.email.tool_email_update.md@@ -0,0 +1,28 @@+### email_update+send progress or status email to user without ending your task+use when working on long tasks keep user informed while continuing work+does NOT end your agentic loop use "response" tool for final answer+usage:+~~~json+{+ ...+ "tool_name": "email_update",+ "tool_args": {+ "text": "... Completed step 1 of 3..."+ }+}+~~~++optional attach files with attachments+~~~json+{+ ...+ "tool_name": "email_update",+ "tool_args": {+ "text": "... preliminary results ...",+ "attachments": [+ "/path/report.csv"+ ]+ }+}+~~~diff --git a/plugins/_email_integration/prompts/fw.email.update_error.md b/plugins/_email_integration/prompts/fw.email.update_error.mdnew file mode 100644index 000000000..505962287--- /dev/null+++ b/plugins/_email_integration/prompts/fw.email.update_error.md@@ -0,0 +1 @@+email update failed: {{error}}diff --git a/plugins/_email_integration/prompts/fw.email.update_ok.md b/plugins/_email_integration/prompts/fw.email.update_ok.mdnew file mode 100644index 000000000..35f2c49fa--- /dev/null+++ b/plugins/_email_integration/prompts/fw.email.update_ok.md@@ -0,0 +1 @@+email update sent, continue workingdiff --git a/plugins/_email_integration/tools/email_update.py b/plugins/_email_integration/tools/email_update.pynew file mode 100644index 000000000..647fdbee4--- /dev/null+++ b/plugins/_email_integration/tools/email_update.py@@ -0,0 +1,36 @@+"""Send progress email without ending the agent loop."""++from helpers.tool import Tool, Response+from plugins._email_integration.helpers.dispatcher import CTX_EMAIL_HANDLER+++class EmailUpdate(Tool):++ async def execute(self, **kwargs) -> Response:+ if not self.agent.context.data.get(CTX_EMAIL_HANDLER):+ return Response(+ message=self.agent.read_prompt(+ "fw.email.update_error.md",+ error="not in an email session"),+ break_loop=False,+ )++ text = self.args.get("text", "")+ if not text:+ return Response(+ message=self.agent.read_prompt(+ "fw.email.update_error.md",+ error="text is required",+ ),+ break_loop=False,+ )++ attachments = list(self.args.get("attachments", []))++ from plugins._email_integration.helpers.handler import send_email_reply+ await send_email_reply(self.agent.context, text, attachments or None)++ return Response(+ message=self.agent.read_prompt("fw.email.update_ok.md"),+ break_loop=False,+ )