Research a prospect and draft three cold-email variants with subject lines scored by predicted reply rate before you send.
You are a senior outbound copywriter. You write cold emails that get replies because they sound human, name a real trigger, and ask one specific question. WORKFLOW: 1. Call research_prospect on the target's name, role, company, and any URL. 2. Call draft_variants to produce three emails: opener (curiosity), value-led (concrete proof), breakup (last attempt). 3. For each, call score_subject_lines to rank 5 candidate subject lines by predicted reply rate. 4. Optional: call send_test to send the chosen variant to the user's inbox for QA. RULES: - Every email must reference one specific trigger (hire, funding, post, launch, integration). - No more than 90 words per email body. - Never use "I hope this email finds you well" or any AI-tell phrase. - Subject lines max 6 words, no question marks unless asking something specific. - If research returns nothing usable, refuse to write the email.
import { agent, tool } from "@agent-sdk"
import Exa from "exa-js"
import { z } from "zod"
const researchInput = z.object({
name: z.string(),
company: z.string(),
role: z.string().optional(),
url: z.string().url().optional(),
})
const draftInput = z.object({
research: z.any(),
offer: z.string(),
cta: z.string(),
})
export default agent({
model: "claude-sonnet-4-6",
permissionMode: "bypassPermissions",
maxTurns: 15,
systemPrompt: `...`, // see System Prompt section above
tools: {
research_prospect: tool({
description: "Find a real trigger to reference",
inputSchema: researchInput,
execute: async ({ name, company, role, url }) => {
const exa = new Exa(process.env.EXA_API_KEY)
const q = `${name} ${company} ${role ?? ""}`.trim()
return exa.search(q, { numResults: 6, contents: { text: true } })
},
}),
draft_variants: tool({
description: "Produce opener, value-led, and breakup variants",
inputSchema: draftInput,
execute: async ({ research, offer, cta }) => {
// returns { opener, valueLed, breakup }
},
}),
score_subject_lines: tool({
description: "Rank 5 candidate subject lines by predicted reply rate",
inputSchema: z.object({ candidates: z.array(z.string()).length(5) }),
execute: async ({ candidates }) => {
// returns ranked array with predicted reply rate
},
}),
send_test: tool({
description: "Send chosen variant to the user's own inbox for QA",
inputSchema: z.object({ to: z.string().email(), variant: z.any() }),
execute: async ({ to, variant }) => {
// POST to AgentMail send
},
}),
},
})EXA_API_KEYExa.ai key for prospect researchAGENTMAIL_API_KEYAgentMail key for QA test sendsAGENTMAIL_INBOX_IDSender inbox IDAn SDR costs $7k/mo loaded and writes 30 emails a day with worse triggers than this agent. Replace the writing, keep the human for replies.