Autonomous AI sales agent powered by Claude Code or Codex. Finds prospects, writes cold emails, sends campaigns, handles replies, books meetings. No API keys needed — runs on your Claude or Codex subscriptions.
Check new recipients with Precleared before the first sequence email
Gabe AO880d1e7317f2
diff --git a/harvey/agents/sender.py b/harvey/agents/sender.pyindex 988bc66..5343bae 100644--- a/harvey/agents/sender.py+++ b/harvey/agents/sender.py@@ -21,6 +21,7 @@ from harvey.config import HarveyConfig, EnvConfigfrom harvey.gate import pre_send_checkfrom harvey.integrations.instantly import InstantlyClientfrom harvey.integrations.mail_provider import NATIVE_PROVIDERS, get_mail_provider+from harvey.integrations.precleared import PreclearedClientfrom harvey.state import StateManagerlogger = logging.getLogger("harvey.sender")@@ -62,6 +63,8 @@ class Sender:self.config = configself.instantly = InstantlyClient(env.instantly_api_key)self.provider = get_mail_provider(config, env)+ # Optional per-recipient compliance check; None unless enabled.+ self.precleared = PreclearedClient.from_config(config, env)# Disabled in tests to skip inter-send sleeps.self.send_pacing = True@@ -442,9 +445,15 @@ class Sender:allow_risky = getattr(self.config.channels.email, "send_to_risky", False)sent = 0+ # Set when Precleared can't be asked (allowance used up, network):+ # cold emails wait for a later cycle, replies still go out.+ compliance_paused = Falsefor item in due:if sent >= budget:break+ needs_check = self.precleared is not None and item["kind"] == "sequence"+ if needs_check and compliance_paused:+ continueprospect = await self.state.get_prospect(item["prospect_id"])if prospect is None:@@ -476,6 +485,30 @@ class Sender:)continue+ # Optional compliance check (compliance.precleared): one per+ # address, before the first cold email. Replies are never checked.+ receipt_id = ""+ if needs_check:+ clearance = await self.precleared.clear(item["to_email"], self.state)+ if clearance.held:+ compliance_paused = True+ logger.warning(+ f"Sender: compliance check unavailable, holding cold "+ f"email until a later cycle: {clearance.reason}"+ )+ continue+ if not clearance.allowed:+ await self.state.update_outbox_item(+ item["id"], status="failed",+ error=f"precleared: {clearance.verdict}: {clearance.reason}"[:300],+ )+ logger.warning(+ f"Sender: Precleared held back email to {item['to_email']}: "+ f"{clearance.verdict} ({clearance.reason})"+ )+ continue+ receipt_id = clearance.receipt_id+result = await self.provider.send_email(item["to_email"], item["subject"], item["body"],thread_ref=item.get("thread_ref", ""),@@ -510,13 +543,16 @@ class Sender:)except Exception as e:logger.debug(f"Sender: convo append failed: {e}")+ details = {+ "to": item["to_email"], "step": item["step"],+ "kind": item["kind"], "provider": self.provider.name,+ }+ if receipt_id:+ details["precleared_receipt"] = receipt_idawait self.state.log_action(action_type="email_sent",agent="sender",- details={- "to": item["to_email"], "step": item["step"],- "kind": item["kind"], "provider": self.provider.name,- },+ details=details,)logger.info(f"Sender: sent step {item['step']} to {item['to_email']} "