Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(ai): draft emails via the email tool (macro-1913) (#4195)

Eric Hayes6f115f6d225c
diff --git a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts b/js/app/packages/service-clients/service-cognition/generated/tools/types.ts
index f3fdccc9a1..5f0e9c61c7 100644
--- a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts
+++ b/js/app/packages/service-clients/service-cognition/generated/tools/types.ts
@@ -2342,7 +2342,7 @@ export interface SearchToolResponse {
results: UnifiedSearchResponseItem[];
}
/**
- * Compose and send an email. Creates the message and immediately queues it for delivery. To reply to an existing message, provide the replying_to_id. Write the body in Markdown — use **bold**, *italics*, lists, links, and other standard Markdown formatting. The draft composer renders the Markdown for the user to review and edit; the composer produces HTML that is sent as the actual email body.
+ * Draft, compose, and send an email. ALWAYS use this tool whenever the user asks you to draft, write, compose, or send an email (or reply to one) — never write the email as plain text in the chat. This tool opens the email draft in the composer for the user to review, edit, and confirm before it is sent, so it is the correct tool even when the user only wants a draft. To reply to an existing message, provide the replying_to_id. Write the body in Markdown — use **bold**, *italics*, lists, links, and other standard Markdown formatting. The draft composer renders the Markdown for the user to review and edit; the composer produces HTML that is sent as the actual email body.
*/
export interface SendEmail {
/**
diff --git a/rust/cloud-storage/email/src/inbound/toolset/send_email.rs b/rust/cloud-storage/email/src/inbound/toolset/send_email.rs
index 16ae822df2..edc0912313 100644
--- a/rust/cloud-storage/email/src/inbound/toolset/send_email.rs
+++ b/rust/cloud-storage/email/src/inbound/toolset/send_email.rs
@@ -39,7 +39,7 @@ impl From<EmailRecipient> for ContactInfo {
#[derive(Debug, Deserialize, JsonSchema, Clone)]
#[schemars(
title = "SendEmail",
- description = "Compose and send an email. Creates the message and immediately queues it for delivery. To reply to an existing message, provide the replying_to_id. Write the body in Markdown — use **bold**, *italics*, lists, links, and other standard Markdown formatting. The draft composer renders the Markdown for the user to review and edit; the composer produces HTML that is sent as the actual email body."
+ description = "Draft, compose, and send an email. ALWAYS use this tool whenever the user asks you to draft, write, compose, or send an email (or reply to one) — never write the email as plain text in the chat. This tool opens the email draft in the composer for the user to review, edit, and confirm before it is sent, so it is the correct tool even when the user only wants a draft. To reply to an existing message, provide the replying_to_id. Write the body in Markdown — use **bold**, *italics*, lists, links, and other standard Markdown formatting. The draft composer renders the Markdown for the user to review and edit; the composer produces HTML that is sent as the actual email body."
)]
#[serde(rename_all = "camelCase")]
pub struct SendEmail {
diff --git a/rust/cloud-storage/prompt/src/tool_usage.rs b/rust/cloud-storage/prompt/src/tool_usage.rs
index 5d3661dd89..7696d512be 100644
--- a/rust/cloud-storage/prompt/src/tool_usage.rs
+++ b/rust/cloud-storage/prompt/src/tool_usage.rs
@@ -27,6 +27,13 @@ static INSTRUCTIONS: &str = r##"## Tone and Style Additions
using XML mention tags (e.g. `<m-document-mention>`). Always use a mention if the tool
returns anything relavent. IMPORTANT
+- IMPORTANT: When the user asks you to draft, write, compose, or send an email (or reply to one),
+ you MUST use the `SendEmail` tool to produce it. NEVER write the email body as plain text in the
+ chat. The `SendEmail` tool opens a real draft in the email composer that the user can review,
+ edit, and send — writing the email inline in chat does none of that and is wrong. Drafting and
+ sending are the same tool: it always creates a draft for the user to confirm before anything is
+ sent, so use it even when the user only wants a draft.
+
- IMPORTANT: The code execution tools (`bash_code_execution`, and `text_editor_code_execution`) should only be used
when the user explicitely asks you to _execute_ code.
@@ -60,7 +67,8 @@ users workspace. If the user asks you to create a document, write a code file, o
static INTENT: &str = "The model proactively uses tools with precise filters instead of \
claiming it lacks context, cites relevant tool results with mention tags, reserves code \
-execution for explicit requests, and uses CreateDocument for files in the user's workspace.";
+execution for explicit requests, uses the SendEmail tool to draft or send emails instead of \
+writing them inline in chat, and uses CreateDocument for files in the user's workspace.";
/// The tool-use prompt.
pub static PROMPT: StaticPrompt<'static> = StaticPrompt::borrowed(TITLE, INSTRUCTIONS, INTENT);